重写不与虚拟主机一起工作

发布于 2025-01-21 03:30:55 字数 1533 浏览 1 评论 0原文

使用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_classjsCSS文件夹。

每次我必须访问:

  • 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 is
C:/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文