mod-rewrite

mod_rewrite “too many redirects” problem

◇◆丶佛笑我妖孽 提交于 2019-12-13 19:27:55
问题 Trying, <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_METHOD} ^TRACE RewriteRule .* - [F] RewriteCond %{HTTP_HOST} ^(.*)dev\.example\.edu$ [NC] RewriteRule ^/test(.*)$ http://dev.example.edu/test/index.php/test$1 [NC] </IfModule> on an apache 2.2 server, to get this rewrite working to hide the "index.php/test" part of the path. everything i've tried either loops the url part (index.php/test) within the address bar or gives a "too many redirects" error. i suspect that the

Htaccess rewrite url to hash anchor on homepage

淺唱寂寞╮ 提交于 2019-12-13 19:27:29
问题 I need to create an htaccess rule for a website i built in codeigniter for an apache web server. I basically have a one page website which displays sections of the site on the the homepage. for example... http://www.example.com/sales http://www.example.com/portfolio ...all appear as sections on the homepage so it display on one page only My plan is to use anchor tags and hashes to direct the user to the right area on the homepage but I can't figure out the correct htaccess rule to modify the

htaccess rewrite condition not working

喜欢而已 提交于 2019-12-13 19:27:09
问题 I am working on URL of my website. I have just rewrite the URL From http://www.website.com/index.php?url=some-text to http://www.website.com/some-text For this I'm using following code of .htaccess Options +SymLinksIfOwnerMatch RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?url=$1 [L,QSA] Now, I want to add another variable page number in URL. http://www.website.com/index

Friendly URLs spaces to hyphens & uppercase to lowercase

二次信任 提交于 2019-12-13 19:19:06
问题 I'd like to convert spaces in dynamic URLs to use hyphens, and if there are any uppercase letters in the URL then it would make them lowercase. spaces to hyphens example www.site.com/article/id/ title goes here -> www.site.com/article/id/ title-goes-here uppercase to lowercase example www.site.com/article/id/ Title-Goes-Here -> www.site.com/article/id/ title-goes-here My current .htaccess file rules. RewriteEngine on # add www before hostname RewriteCond %{HTTP_HOST} ^site\.co$ [NC]

Rewrite a url with one non-breaking space in .htaccess

浪子不回头ぞ 提交于 2019-12-13 19:17:12
问题 I have the following url (there are a few like these): mysite.co.uk/productdetails/408/20/Casio%C2%A0CTK1100/ and I want to rewrite it to: mysite.co.uk/Casio-CTK1100-in-Black/393 The problem is this funny %C2%A0 now I have other links with multiple spaces in there and they are rewritten as follows: # take care of %C2%A0 RewriteRule ^(.+)\xc2\xa0(.+)$ $1-$2 [L,NE] # executes **repeatedly** as long as there are more than 1 spaces in URI RewriteRule "^(\S*) +(\S* .*)$" $1-$2 [L,NE] RewriteRule "

Rewrite condition to check mobile user agent from smart phones

一个人想着一个人 提交于 2019-12-13 19:08:23
问题 I am writing rewrite condition to check user agent. 1. The request should be from Mobile and 2. The request should not be from iphone/Black Berry/Android Device/ Windows Phone I got some thing like this RewriteCond %{HTTP_USER_AGENT} Mobile [AND] RewriteCond %{HTTP_USER_AGENT} !"android|blackberry|IOS|windows phone" [NC] Can some one correct this. 回答1: RewriteCond %{HTTP_USER_AGENT} ^.*(Android|BlackBerry|iPhone|Windows Phone).*$ [NC] RewriteRule ^(.+)$ /go_to_mobile_or_403/$1 [L] source:

Replace 4 digit in URL by text + 4 digit

柔情痞子 提交于 2019-12-13 19:01:10
问题 Using .htaccess, I need to replace the following URL: www.domain.com/1234-text.... By: www.domain.com/item/1234-text.... This is what I'm trying: RewriteRule ^[0-9][0-9][0-9][0-9]-/(.*)$ https://www.domain.com/item/[0-9][0-9][0-9][0-9]-/$1 [R=301,L] I've been exploring the Regex wiki but couldn't find the right expression. 回答1: Try this rule: RewriteRule ^(\d{4}-.*)$ /item/$1 [R=301,L] 回答2: Try instead: RewriteRule ^([0-9]{4}\-.*)$ https://www.domain.com/item/$1 [R,L] 来源: https:/

Problems with Wordpress’ mod_rewrite rules when requesting existing files

六眼飞鱼酱① 提交于 2019-12-13 18:25:19
问题 please take a look at my .htaccess: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress For Wordpress it works fine. But I have a

htaccess subdomain redirect to port while keeping original url

。_饼干妹妹 提交于 2019-12-13 18:07:17
问题 I have trouble getting this to work properly, what I'm trying to do is make http://subdomain.domain.com redirect to domain.com:8080 while keeping the original url "subdomain.domain.com" Code so far: RewriteEngine on RewriteCond %{HTTP_HOST} subdomain.domain.com RewriteRule ^(.*)$ http://%1domain.com:8080$1 [L] Which does the redirect, but browser url changes to "http://domain.com:8080" which is not what I seek. Thank you in advance! 回答1: For this to happen you need to enable mod_proxy in

Redirecting to backend via htaccess Yii2

好久不见. 提交于 2019-12-13 17:42:35
问题 I am trying to redirect my url to the admin ( backend ) part on domain/admin via htaccess. Still not very familiar with .htaccess and what I did so far is Main .htaccess in the root directory: #adding the charset AddDefaultCharset utf-8 #hide the structure Options -Indexes #if dir is symbol, follow it Options FollowSymlinks #engine on RewriteEngine #if there is admin word in the URI go on the next rule RewriteCond %{REQUEST_URI} ^/admin$ #load the backend index file, append the group to the