这是我的.htaccess文件: RewriteEngine on RewriteBase /admin RewriteRule menu/([0-9]+)/([0-9]+)/([a-z0-9]+) http://www.mysite.com/admin/index.php?m=$1&o=$2&token=$3 [R,L] 我必须包含完整的URL,因为没有它,它会一直redirect到http://www.mysite.com/menu/1/1/login.php而不是mysite.com/admin/login.php 所以我重写了我的链接,所以他们看起来像这样: <a href="/admin/menu/1/1/bl4h1234">Some link</a> 这工作正常,但url在地址栏中显示为丑陋的URL,但整体目的是显示该URL作为漂亮的URL:/ 我该如何解决这个问题?
我在这个问题上遇到了非常艰难的时刻,并且尝试了一些解决scheme,这些解决scheme对于某些人而言并不适合我。 首先我设置:Ubuntu 14.04.2 Apache 2.4.7 我目前正在将我的网站迁移到设置为虚拟主机的文件夹结构/ var / www / dev – dev.conf中,内容如下: <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that ServerAdmin ubuntu@12.345.678.90 DocumentRoot /var/www/dev ServerName dev.mysite.com <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/dev/> Options -Indexes +FollowSymLinks AllowOverride All #Require all granted Order allow,deny allow from all […]
我已经把网站从/ blog /移到了web根目录。 我为我的URL创build了一个RedirectMatch 301,我相信这是正确的: RewriteEngine On RewriteBase / RedirectMatch 301 ^/blog/(.*)$ /$1 这工作正常。 现在,domain.tld / blog / foo /redirect到domain.tld / foo / 但是,有一个问题。 在网站上有一个页面,用slu::/ blog / 现在你不能访问页面,因为domain.tld / blog /redirect到domain.tld / 所以我想完成的不是redirect/ blog /,而是redirect/ blog / everything / else / domain.tld / blog /不redirect domain.tld / blog / foo /redirect到domain.tld / foo / domain.tld […]
我一直在试图pipe理从www.domain.com到domain.com的redirect,但似乎没有任何效果。 我总是得到一个redirect循环 – 我尝试了各种在Google或Google上find的东西。 所以这里是我的.htaccess,也许有人可以帮我弄清楚我能做些什么来正确redirect,或者如果在这里有什么问题。 RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] # Redirect all to .php # Example: example.com/hello -> example.com/hello.php RewriteRule ^(.*)$ $1.php [L,R=301] # show example.com/index.php always as example.com/ RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://example.com/ [R=301,L] 非常感谢! 我已经花了这么多的时间来解决这个问题了。
我正在尝试将所有HTTP请求redirect到HTTPS,并将所有wwwredirect到非www URL。 那是, http://example.net到https://example.net http://www.example.net到https://example.net http://www.example.net到https://example.net https://www.example.net到https://example.net 我成功地能够redirectURL条件(1,2&3),但第4个redirect条件不起作用,即https://www.example.net到https://example.net 。 我的网站有www和非wwwurl的SSL证书。 我目前正在使用WordPress。 我的.htaccess文件包含以下代码: RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC] RewriteRule (.*) https://%1%{REQUEST_URI} [L,R=301] 我已经尝试了许多不同的redirect条件,但没有工作。 我在Firefox中得到以下错误: 连接www.example.net时发生错误。 同行报告它遇到一个内部错误。 错误代码:SSL_ERROR_INTERNAL_ERROR_ALERT 我能做些什么来redirect第四个URL的条件?
我道歉,如果标题不是很清楚,因为我是新来的mod_rewrite,我不知道如何正确地短语问题。 我想重写一个奇特的URL,如http://www.url.com/module/subdirectory/another_subdirectory/page到http://www.url.com/d_1=module&d_2=subdirectory&d_3=another_subdirectory&page=page 。 子目录的数量是变化的,所以参数d_ *可以是dynamic的(试图保持它在d_1和d_9之间)。 花哨的url也可以有自己的查询string,并且需要在page参数之后重写。 我读了Apache的mod_rewrite和正则expression式文档,花了一些时间在Google和Stackoverflow上寻找答案,但找不到这个问题。 任何帮助这个问题的人更knowledgable将不胜感激。
我刚刚意识到我的htaccess在某些情况下会产生双重301redirect。 例如,如果您尝试访问http://example.com/old_url,它将会: 首先301到http://www.example.com/old_url (增加www) 然后301到http://www.example.com/new_url (更改为新url) 以下是我的htaccess的设置: RewriteEngine On # Add www RewriteCond %{HTTP_HOST} ^example.com [nocase] RewriteRule ^(.*) http://www.example.com/$1 [last,redirect=301] # Do some url rewriting RewriteRule ^new_url_1$ new_url_1.php [NC,L] RewriteRule ^new_url_2$ new_url_2.php [NC,L] # Do the 301 redirections Redirect 301 /old_url_1 http://www.example.com/new_url_1 Redirect 301 /old_url_2 http://www.example.com/new_url_2 我怎样才能解决,只有一个301更好的search引擎优化? 谢谢!
我有一个基于Joomla 2.5的网站,我试图在最后使用随机代码redirect包含/RK=0/RS= URL。 他们导致我的服务器的访问日志中的404错误。 这里有一些样品: /blog/name-of-blog-post.html/RK=0/RS=_ep9ZOcaWbdT5g4pr_m9ddy3Rxo- 我发现了几个解决scheme,不适合我: RewriteEngine On RewriteRule ^(.*)/RK=0/RS= /$1 [L,NC,R=301] RewriteRule ^/blog/(.*)/RK=0/RS= /$1 [L,NC,R=301] RewriteRule ^/blog/(.*)(.html)/RK=0/RS= /$1 [L,NC,R=301] RewriteRule ^/blog/(.*)(.html)/RK=0/RS=(.*) /$1 [L,NC,R=301] RewriteRule ^(.*)RK=0/RS= /$1 [L,NC,R=301] RewriteRule ^(.*)RS=^ /$1 [L,NC,R=301] RewriteRule ^(.*)RK= /$1 [L,NC,R=301] RewriteRule ^(.*)/RK= /$1 [L,NC,R=301] 在提供的示例中,如何编写重写以捕获和删除/RK=0/RS=_ep9ZOcaWbdT5g4pr_m9ddy3Rxo-任何想法? 我有数以百计的这些不同的随机代码在URL的末尾。
我有一个HTML5模式的路线angular项目。 我设置了一个htaccess文件,可以手动插入域或刷新页面。 这里的工作正常的htaccess代码,基于这个仍然得到'未find'时手动刷新angular.js路线 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ – [L] RewriteRule ^ myFolder/myFile.php [L] 但现在我想也redirect到https宽度万维网的URL,例如: http://example.com应该成为https://www.example.com 那里为我使用这个: RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 但是,当我试图结合这个脚本我总是得到错误! 谢谢!
我希望(.htaccess)重写具有“custom_title”参数的search查询的url。 任何人都可以帮助我? 我想重写这个url: http://www.mysite.com/search.php?search_query=myquery&custom_title=mytitle 对此: http://www.mysite.com/results/myquery/mytitle/