开发者

mod_rewrite Probs

I am quite new to PHP and just getting started with mod_rewrite. I know the ba开发者_运维百科sic lingo but come stuck when I want to simply refer to the route directory

i.e. this is not probs

RewriteRule ^settings/$ settings.php [QSA,L]

But how to for example make:

RewriteRule ^page/(.*)$ index.php?Page=$1 [QSA,L]

which generates /page/[page-name]

Just become

/[page-name]

?


Maybe I didn't understand you but it seems that you need such .htaccess file to solve your problem.

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteBase /

  # Ignore valid files
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d    

  RewriteRule ^(.*)$ index.php?Page=$1 [QSA,L]
</IfModule>


This should do it:

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

However, you should place that rewrite rule after all the other specific rewrite rules you have, otherwise all requests will be redirected to index.php?Page=....

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜