我有一个目录在我的网站根projectae/project/index.php,我想改变目录名只在url,但在根仍然有projectae,所以我想改变
localhost/projectae/project/index.php
to
localhost/ae/project
我在htaccess上做了一些尝试,但都没有成功。
RewriteCond %{THE_REQUEST} ^GET\ /projectae/
RewriteRule ^projectae/(.*)$ /ae/$1 [L]
我也试过
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^pojectae/project/$ /ae/project/$1 [L]
我确实清除了缓存中没有什么工作;我重新启动apache没有任何工作我的配置文件:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
</VirtualHost>
1条答案
按热度按时间yshpjwxd1#
你的描述暗示你想以相反的方式重写:
典型的组合是组合重定向和重写的规则:
这些规则在http服务器中央主机配置或分布式配置文件中的工作方式相同(.“htaccess”样式的文件)。如果你真的必须使用这样的分布式文件,那么注意在你的主机配置中启用它的考虑(请参阅
AllowOverride
指令的文档),并且上述规则被放置在http主机的DOCUMENT_ROOT
文件夹内的这样一个文件中。