Friendly URLs with .htacces NOT working… and stackoverflow URLs style

荒凉一梦 提交于 2019-12-08 09:56:39

问题


I know this question has been asked a million of times here at stackoverflow, but I cant get it to work so I need someone who knows to finally resolve this problem!

I want that when this is inserted in the URL:

http://website.com/pelicula/0221889/
http://website.com/pelicula/0221889/posters/

It really goes to this:

http://website.com/index.php?ctrl=pelicula&id=0160399
http://website.com/index.php?ctrl=pelicula&id=0160399&tab=posters

This is how my .htacces file looks like:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^/([^/]+)/([^/]+)/?([^/]*)/?$ index.php?ctrl=$1&id=$2&tab=$3 [QSA,L]
</IfModule>

But its not working! I just get a 'Not found' error in my web server (only when using the friendly URL, regular is still working fine). How to fix this?

I would also want to know how to be able to add anything at the end of the URL without getting any errors (like stackoverflow URLs).

Like this:

http://website.com/pelicula/0221889/any-text-i-want-to-put
http://stackoverflow.com/questions/3033407/htacces-to-create-friendly-urls-help-needed

I hope someone can give me an answer, thanks!


回答1:


I read all of your threads so I'm not going to reiterate what others have said or asked. I'm just throwing out ideas here but...

Sounds like rewrite is working - it's actually redirecting correctly - but it's pointing you to a page that is not found. Have you tried using RewriteBase?

RewriteEngine On
RewriteBase /


来源:https://stackoverflow.com/questions/3052682/friendly-urls-with-htacces-not-working-and-stackoverflow-urls-style

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!