URL Rewriting doesn't rewrite automatically

后端 未结 3 1184
忘掉有多难
忘掉有多难 2021-01-15 18:10

I have this simple redirection on my website and it does not rewrite my url automatically, I have to type manual other URL to access it, what could be the problem, do I need

相关标签:
3条回答
  • 2021-01-15 18:40

    check your apache config (httpd.conf) see whether it allowing to overriding the htaccess

    http://httpd.apache.org/docs/2.0/howto/htaccess.html

    0 讨论(0)
  • 2021-01-15 18:48

    If you are doing it in .htaccess you should also specify RewriteBase /. Try

    RewriteEngine On
    RewriteBase /
    RewriteRule ^new-page-([^/]*)\.php$ mypage.php?name=$1 [L]
    

    This rewrites new-page-something.php tomypage.php?name=something internally.

    ADDED:

    Perhaps you want this:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^new-page-([^/]*)\.php$ mypage.php?name=$1 [L]
    RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD|TRACE)\ /mypage.php
    RewriteCond %{QUERY_STRING} name=([^\&]*)
    RewriteRule ^mypage.php$ new-page-%1.php? [R,L]
    

    The first added RewriteCond checks whether the real request is requesting for /mypage.php to prevent a redirect loop. The second added RewriteCond is used to match the query string for use in RewriteRule.

    0 讨论(0)
  • 2021-01-15 18:48

    I have the following link

    www.preparationweb.com/Aptitude/Discussion/index.php?qid=26

    I like it to appear it as

    www.preparationweb.com/Aptitude/Discussion/26

    Can you please provide me the code to be placed in .htaccess file according to the provided link. I have a godaddy hosting.

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