【问题标题】:How To rewrite the URL using apache如何使用 apache 重写 URL
【发布时间】:2020-01-31 08:22:36
【问题描述】:

这是示例网址。我想如何在 apache 中使用 conf 文件重写 URL。

http://test.local/index.cfm/a/b/http://test.local/a/b/

<VirtualHost 127.0.0.1:80>  
    DocumentRoot "LocalPath"    
    ServerName alias

    Alias "/CFFileServlet" "C:\ColdFusion2018\cfusion\tmpCache\CFFileServlet"

    <Directory "LocalPath">
        AllowOverride All
        Order allow,deny
        Allow from All
        Options MultiViews Indexes
    </Directory> </VirtualHost>

【问题讨论】:

  • 那么,问题是什么?你想知道如何写模式吗?或者放在配置中指定重写?
  • @TemaTre,图案怎么写,放在哪里?
  • 你用的是什么操作系统?
  • 我的回答对你有帮助吗?

标签: apache .htaccess url-rewriting


【解决方案1】:

你应该在配置中指定它。

例如在 Linux 操作系统中,运行:

sudo nano /etc/apache2/sites-available/default

这包含类似这样的内容:

 <VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

那么你应该指定重写规则:

<Directory "/var/www/">
  RewriteEngine on
  RedirectMatch "^/index.cfm/(.*) " "/$1"
</Directory>

它可以是另一种模式,这取决于您的目标和网站设置。

【讨论】:

  • 这不起作用。它的抛出错误如 Bad request
  • 请提供有问题的完整配置列表。
  • 我已经添加了完整的配置
猜你喜欢
  • 2012-12-21
  • 1970-01-01
  • 2012-11-13
  • 1970-01-01
  • 2013-06-09
  • 1970-01-01
  • 2012-03-26
  • 2011-11-10
  • 2017-04-20
相关资源
最近更新 更多