Php mod_rewrite is not working properly

后端 未结 2 1777
温柔的废话
温柔的废话 2021-01-26 12:36

I\'ve a php page with following link structure:

http://localhost/wisper/businesspage.php?profile=creativeartbd

So I\'m trying to convert this

相关标签:
2条回答
  • 2021-01-26 13:24

    This ruleset should work for you:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteCond $1 !^businesspage.php
    RewriteRule ^wisper/(.*?)$ wisper/businesspage.php?profile=$1 [QSA,L]
    

    Please note the RewriteCond in the 6th line: it tells mod_rewrite not to rewrite the wisper/businesspage.php, thus avoiding loops.

    0 讨论(0)
  • 2021-01-26 13:29

    You are doing it wrong try this

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteBase /
    RewriteRule ^wisperpage/(.*?)$ wisper/businesspage.php?profile=$1 [QSA,L]
    

    You need to change the first uri segment because rewriting wisper/creativeartbd to wisper/businesspage.php?profile=$1 will creates the infinite loop

    0 讨论(0)
提交回复
热议问题