简体   繁体   English

htaccess重写规则REQUEST URI问题

[英]htaccess Rewrite Rule REQUEST URI Issue

if site name does not have REQUEST URI then index.php should come else if URL is example.com/key the file pages.php?tkey=key should come. 如果站点名称没有REQUEST URI,那么如果URL是example.com/key,则index.php应该出现,而文件pages.php?tkey = key应该来了。

When I set this way images in subfolders are not loading 当我这样设置子文件夹中的图像没有加载

RewriteRule ^/?$ index.php [L]
RewriteRule ^(.*)$ pages.php?page_keytkey=$1 [L]

Please advice 请指教

Try preventing the recursive loop that Peter Szymkowski pointed out . 尝试防止Peter Szymkowski指出的递归循环。 Also consider not redirecting existing files as Michael Berkowski said . 还要考虑不像Michael Berkowski所说的那样重定向现有文件。

RewriteRule ^/?$ index.php [L]
RewriteCond %{REQUEST_URI} !^/pages.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ pages.php?page_keytkey=$1 [L]

You can read more at http://wiki.apache.org/httpd/RewriteCond for example. 您可以在http://wiki.apache.org/httpd/RewriteCond上阅读更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM