English 中文(简体)
获取不同要求的相同要求信息信息
原标题:Getting the same REQUEST_FILENAME for different REQUEST_URI

与新版版本有奇特的问题。

类似 /news 的 URI 将正确匹配, 因为 news.php 已经存在。 但是, /news/1900-01-01/ title 将和 /news 一样匹配!

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$ #workaround for URIs ending in a slash passing the previous check
RewriteRule ^(.*)$ debug.php?page=$1.php&req_filename=%{REQUEST_FILENAME}&req_uri=%{REQUEST_URI} [L]

如果使用 /news 运行,则产生预期结果:

page=/news.php
req_filename=/home/domain/public_html/news
req_uri=/news

如果以 /news/1900-01-01/标题 运行,则产生:

page=/news/1900-01-01/title.php
req_filename=/home/domain/public_html/news
req_uri=/news/1900-01-01/title

为何这两个词的reQeste_FILENAME}{/code>都是一样的?

我已经对新闻项目有一个变通办法; 将 < code> rewrite Rules {news/ ([0- 9]{4}- [0- 9]{2}- [0- 9}{2}) / ([a- zA- Z0- 9-]+]$ new- items.php?date= 1 & amp; title= 2 [L] 移至此片段上方。 但是, 我想了解 2个独特的 URIs 如何解决相同的非性别歧视者( 文稿添加了.php) 文件 。

最佳回答

Apache 试图找到最小的“ 真实” 目录, 然后处理与该目录对应的指令( 例如. htaccess 或其他 dir 特定指令 ) 。 在您的情况中, 我假设 URI 与任何真实目录不匹配。 Apache 然后使用内容谈判, 如果设置了多视图( 我怀疑在您的情况中是这样 ), 那么它会发现基于文件名的最佳匹配 。 既然您有新闻.php, 那么它就是匹配的 。 如果您想要获得更多的页面, 您可以查看解释关键字的内容谈判和多维ws 。

问题回答

暂无回答




相关问题
Ignore symlinks in clean URL s in .htaccess

Example URL: example.com/user /user is both a symlinked directory and a valid URL to content on my site. I user Horde Routes to request the content and all requests to the site go through index.php. ...

.htaccess File Options -Indexes on Subdirectories

I have the following .htaccess line, simple no indexes on root. Options -Indexes What do we add so it propagates to any sub directory instead of having to create one file for each? One .htaccess on ...

Mod Rewrite ignoring -d

After a day or two, I am still fighting with Mod Rewrite. It seems that 60% of my development time is spent battling the server. My current URL structure is such that all http://example.com/xyz and ...

ErrorDocument 404 Not Sending Referrer Information: PHP

I m using a standard htaccess ErrorDocument 404 to redirect users to a new page. In order to customize the 404, I need to know their referrer information (from the page they Tried to visit). $...

Find all htaccess files on server [closed]

I m looking for a Linux command to go through all the directories on my server and find all .htaccess files. The output would be a list of all those files with full path, creation/modification date ...

301 Redirect Help with Dynamic URL s and Multiple Id s

I just did a redesign for www.wildchildclothes.com which has a new URL structure. The old site ran on Zen Cart and had a bad URL structure. Here are some examples of what I want to redirect from: OLD:...

热门标签