重写不与虚拟主机一起工作
使用XAMPP时,我面临错误。
我的网站是Localhost IE的ECOM,http:// localhost/ecom。同样,开发其他网站表示Idiscuss IE,http:// localhost/idiscuss。
In httpd.conf
----------------
DocumentRoot "C:/xampp/htdocs"
RewriteEngine On
RewriteCond C:/xampp/htdocs/%{REQUEST_FILENAME} !-f
RewriteCond C:/xampp/htdocs/%{REQUEST_FILENAME} !-d
RewriteRule ^/ecom/(.*)$ /ecom/index.php?do=$1&%{QUERY_STRING} [L]
此条件将删除.php扩展名,并将每个请求引导到index.php,即单个入口点。
我的文件结构是 c:/xampp/htdocs/ecom
,又有index.php
和其他php_class
,js
, CSS
文件夹。
每次我必须访问:
- localhost/ecom/ - for默认主页
- localhost/ecom/contactus
- localhost/ecom/product
,我想使用:
- ecom.com- for默认主页
- ecom.com/contactus
- ecom.com/ 产品
实现这一目标的
a) in httpd-vhosts.conf
--------------------------
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/ecom"
ServerName ecom.com
</VirtualHost>
b) hosts file
-----------------
127.0.0.1 ecom.com
c) httpd.conf
---------------------
RewriteEngine On
RewriteCond C:/xampp/htdocs/%{REQUEST_FILENAME} !-f
RewriteCond C:/xampp/htdocs/%{REQUEST_FILENAME} !-d
RewriteRule ^/ecom.com/(.*)$ /ecom/index.php?do=$1&%{QUERY_STRING} [L]
,但它给出了荒谬的结果。 我只能打开主页,即ecom.com,但是当尝试访问ecom.com/product时,它说“请求的URL不存在”。
此外,当尝试访问我正在开发的其他站点时,例如Localhost/Idisucss,它会引发相同的错误:“不存在请求的URL”。
我完全被困,任何帮助将不胜感激。
I am facing an error when using xampp.
My site is ecom on localhost i.e., http://localhost/ecom. Similarly developing other sites say idiscuss i.e., http://localhost/idiscuss.
In httpd.conf
----------------
DocumentRoot "C:/xampp/htdocs"
RewriteEngine On
RewriteCond C:/xampp/htdocs/%{REQUEST_FILENAME} !-f
RewriteCond C:/xampp/htdocs/%{REQUEST_FILENAME} !-d
RewriteRule ^/ecom/(.*)$ /ecom/index.php?do=$1&%{QUERY_STRING} [L]
This condition removes .php extension as well as, directs every request to index.php, i.e., single entry point.
My file structure isC:/xampp/htdocs/ecom
, which in turn has index.php
and other php_class
, js
, css
folders.
Every time I have to access:
- localhost/ecom/ - for default home page
- localhost/ecom/contactus
- localhost/ecom/product
Instead, I want to use:
- ecom.com - for default home page
- ecom.com/contactus
- ecom.com/product
To attain this,
a) in httpd-vhosts.conf
--------------------------
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/ecom"
ServerName ecom.com
</VirtualHost>
b) hosts file
-----------------
127.0.0.1 ecom.com
c) httpd.conf
---------------------
RewriteEngine On
RewriteCond C:/xampp/htdocs/%{REQUEST_FILENAME} !-f
RewriteCond C:/xampp/htdocs/%{REQUEST_FILENAME} !-d
RewriteRule ^/ecom.com/(.*)$ /ecom/index.php?do=$1&%{QUERY_STRING} [L]
But it's giving absurd results.
I am only able to open the home page, i.e., ecom.com, but when trying to access ecom.com/product, it says "requested url doesn't exist".
Moreover, when trying to access other sites that I am developing, e.g., localhost/idisucss, it throws the same error: "requested url doesn't exist".
I am completely stuck, any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论