Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 我如何设置htaccess来执行此操作?_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache 我如何设置htaccess来执行此操作?

Apache 我如何设置htaccess来执行此操作?,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我正在尝试设置htaccess文件以执行以下重定向: http://www.mysite.com/about应链接到http://www.mysite.com/content/pages/about.php http://www.mysite.com/login应链接到http://www.mysite.com/content/pages/login.php http://www.mysite.com/prices应链接到http://www.mysite.com/content/pages/p

我正在尝试设置htaccess文件以执行以下重定向:

http://www.mysite.com/about应链接到http://www.mysite.com/content/pages/about.php

http://www.mysite.com/login应链接到http://www.mysite.com/content/pages/login.php

http://www.mysite.com/prices应链接到http://www.mysite.com/content/pages/prices.php


感谢

仅重定向您提供的URL,您可以使用此类规则(您可以将其他页面添加到您需要的URL列表中):

要将所有不存在的页面重定向到
/content/pages/PAGE\u NAME.php
,可以使用以下规则:

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

# do not do anything for already existing files (like images/css/js etc)
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]

# redirect everything else
RewriteCond %{REQUEST_URI} !^/content/pages/
RewriteRule ^(.+)$ /content/pages/$1.php [L]
注意事项: 您需要将这些规则放入网站根文件夹中的.htaccess中。如果放在其他地方,可能需要一些小的调整

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

# do not do anything for already existing files (like images/css/js etc)
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]

# redirect everything else
RewriteCond %{REQUEST_URI} !^/content/pages/
RewriteRule ^(.+)$ /content/pages/$1.php [L]