.htaccess文件只在子文件夹内,而不是根文件夹

时间:2017-06-10 08:11:13

标签: php apache .htaccess mod-rewrite

我有一个我目前正在更新的网站。我已将所有库,资源,配置等复制到文件夹 newsite 。由于我没有实现任何URL重写根旧网站,我想在更新站点中实现它。因此,我在newsite文件夹中添加了.htaccess文件。下面是文件夹结构。

root/
|-- config/
|-- libraries/
|-- resources/
|-- newsite/
|     |-- config/
|     |-- libraries/
|     |-- resources/
|     |-- index.php
|     |-- .htaccess
|-- index.php
|-- login.php
|-- services.php
|-- contact.php

我希望旧网站能够以现在的方式运行,但我希望将网址重写为新网站。

新网站的网址基本上是:

https://exmple.com/newsite/
https://exmple.com/newsite/services
https://exmple.com/newsite/login
https://exmple.com/newsite/contact

或任何其他网址。以下是我写的重写规则。

RewriteEngine On
RewriteBase /newsite
RewriteCond %{REQUEST_URI} ^/newsite
RewriteRule ^newsite/(.+)$ /newsite/index.php?page_name=$1 [QSA,L]

0 个答案:

没有答案
相关问题