Php 如何使我的Htaccess删除扩展名,同时在目录后没有文件名
我用PHP编写代码,并实现了一个htaccess代码,该代码删除了文件扩展名(在本例中为“.PHP”) 问题是,这不允许目录最终删除index.php 即-在此服务器上找不到请求的URL/about/.php 这是我目前的代码:Php 如何使我的Htaccess删除扩展名,同时在目录后没有文件名,php,.htaccess,Php,.htaccess,我用PHP编写代码,并实现了一个htaccess代码,该代码删除了文件扩展名(在本例中为“.PHP”) 问题是,这不允许目录最终删除index.php 即-在此服务器上找不到请求的URL/about/.php 这是我目前的代码: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTT
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php http://www.domain.com/$1 [R=301,L]
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php/?$ / [L,R=301,NC]
我想让/about/redirect指向/about/index.php,同时显示/about/
提前谢谢各位 只需在htaccess文件中使用DirectorySlash即可 Apache会在目录名后自动附加尾随斜杠
DirectorySlash On
如果要调用不带尾随斜杠的目录,请尝试:
DirectorySlash Off
只需在htaccess文件中使用DirectorySlash Apache会在目录名后自动附加尾随斜杠
DirectorySlash On
如果要调用不带尾随斜杠的目录,请尝试:
DirectorySlash Off
你可以试试这个:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ([^/]+)/? [NC]
RewriteRule .* %1/index.php [L,QSA]
它将无声地映射
http://www.domain.com/anything/
到
http://www.domain.com/anything/index.php
您可以尝试以下方法:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ([^/]+)/? [NC]
RewriteRule .* %1/index.php [L,QSA]
它将无声地映射
http://www.domain.com/anything/
到
http://www.domain.com/anything/index.php
不幸的是,这还没有解决它。它抛出了相同的错误。不幸的是,这并没有修复它。它抛出了同样的错误。