开发者

need help in htaccess

I need my URL to be li开发者_Python百科ke this:

http://example.com/index.php?title=about -> http://example.com/about/

The title more than 50, and same goes to pages.

Any idea? Thanks


Whilst mosg's link does have the answers you're looking for, I figured it might be easier to just explain the part you need.

I'm not sure if you want to redirect index.php?title=about TO /about/, or if you want /about/ to silently call index.php?title=about.

For /about/ -> /index.php?title=about (silently):

RewriteEngine on  # turn on re-writing
RewriteCond %{REQUEST_URI} !^/index\.php.*  # for every non-rewritten request
RewriteRule ^(.*)$ http://%{HTTP_HOST}/index.php?title=$1 [L] # rewrite to index.php

For /index.php?title=about -> /about/ (not silently)

RewriteEngine on  # turn on re-writing
RewriteCond %{REQUEST_URI} ^/index\.php?title=.*  # for index.php?title=slug request
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L] # rewrite to /slug/

Hope this helps :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜