douan4359 2017-03-05 17:18
浏览 30
已采纳

Htaccess URL重写[GET不起作用]

In my site I use "show.php?cat=1" type URLs. I want to change for SEO optimization this link types.

I have tried before but I can't understand how to do that.

# Root Host
-- Project Folder
--- index.php
--- show.php
--- css/js/ and other folders

My first purpose is change my links

show.php?cat=1 to show/1/

my code is

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^/show/(.*)$ show.php?cat=$1 [QSA,L]

But it doesn't work. I have a GET error. What's wrong?

And my css files gone to /show/css URL

I'am very angry, my css files gone but Get function doesn't work.

Thanks for help.

Edit: If I change show code to 'test' like that, page becomes 404. Why? Note: I'am using WAMP Server 3, Apache Rewrite_module is working.

RewriteRule ^/test/(.*)$ show.php?cat=$1 [QSA,L]

"The requested URL /project1/test/1 was not found on this server."

  • 写回答

1条回答 默认 最新

  • douan5151 2017-03-05 18:08
    关注

    Use:

    Options +FollowSymLinks -MultiViews
    RewriteEngine on
    
    RewriteRule ^show/(.*)$ show.php?cat=$1 [QSA,L]
    

    Without first / in htaccess RewriteRule pattern

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?