mod-rewrite

Redirecting www to non-www while maintaining the protocol HTTP or HTTPS

无人久伴 提交于 2020-01-21 09:07:10
问题 I'm attempting to redirect www to non-www for both HTTP and HTTPS requests. My root .htaccess looks like this: RewriteEngine on RewriteCond %{HTTP_HOST} ^www.example.com$ RewriteRule ^(.*)$ http://example.com/$1 [R=301] RewriteCond %{HTTP_HOST} ^www.example.com$ RewriteCond %{SERVER_PORT} ^443 RewriteRule ^(.*)$ https://example.com/$1 [R=301] This isn't fully working as expected. What happens: Visiting http://www.example.com results in a redirect to http://example.com . This indicates my

.htaccess redirecting domain alias'

半腔热情 提交于 2020-01-21 07:35:25
问题 I have a client that has a good amount of domain alias' and wants them all redirected to the one main domain on the site. They also want to know which of the domain alias' is doing the redirecting. I have that part down but I want to optimize the code to the best most proper way it should be and to eliminate the amount of code I have to write. I am wanting to know if there is a way to pass to the RewriteRule url the domain alias that was used. This is what I have now. I am looking for the

How to preserve POST data via ajax request after a .htaccess redirect?

谁都会走 提交于 2020-01-21 07:21:07
问题 .htacesss RewriteCond %{REQUEST_URI} ^/api/(.+)$ RewriteRule ^api/(.+)$ /index.php?api=%1 [QSA,L] example ajax url request: 'http://hostname.com/api/ext/list.php?query=de' I want to be able to redirect urls in this format to the following index.php?api={requested_filename}&param1=value1&param2=value2 ... because the whole site is processed through a bootstrap process in index.php which has a routing part loading configs, templates etc... When I try a jquery code for example, the POST data is

.htaccess RewriteRule works but the URL isn't changing in the address bar?

我只是一个虾纸丫 提交于 2020-01-21 05:26:35
问题 I have been pulling my hair trying to figure this out but nothing is working. I have a webpage at mysite.com/test.php I want to do a simple URL rewrite and change it to mysite.com/testRewrite/ The code to do implement this should be: Options +FollowSymLinks RewriteEngine on RewriteRule ^testRewrite/$ test.php [NC,L] For whatever reason it's just not working. When you go to the new URL - mysite.com/testRewrite/ it works. However, if you type in the original URL mysite.com/test.php it doesn't

.htaccess RewriteRule works but the URL isn't changing in the address bar?

穿精又带淫゛_ 提交于 2020-01-21 05:26:29
问题 I have been pulling my hair trying to figure this out but nothing is working. I have a webpage at mysite.com/test.php I want to do a simple URL rewrite and change it to mysite.com/testRewrite/ The code to do implement this should be: Options +FollowSymLinks RewriteEngine on RewriteRule ^testRewrite/$ test.php [NC,L] For whatever reason it's just not working. When you go to the new URL - mysite.com/testRewrite/ it works. However, if you type in the original URL mysite.com/test.php it doesn't

How do I redirect subdomains that do not exist?

强颜欢笑 提交于 2020-01-21 05:02:24
问题 I am trying to redirect using .htaccess in the following fashion. I am not all that familiar with .htaccess, so I'm not sure it can be done. Also, I don't know if how I am intending to do it follows best practices for SEO. www.domain.com > domain.com 301 ks.domain.com > kansas.domain.com 301 ia.domain.com > iowa.domain.com 301 domain.com/sites > domain.com 301 domain.com/sites/iowa > iowa.domain.com 301 nonexistent.domain.com > domain.com 302 domain.com/sites/nonexistent > domain.com 302 My

Modern favicons & htaccess rewrite rule

限于喜欢 提交于 2020-01-20 08:52:45
问题 Instead of having all the new favicon formats placed into the root directory of my website, I am placing them inside a subfolder. To conform to the standards, as some browsers / device versions do not use the path as directed inside the html meta tags, but instead try to get the file from the website root anyway, I am creating a rewrite rule to redirect all these files to the actual location - but ONLY these files. What I have come up with so far is the following : RewriteEngine On

Mod rewrite using .htaccess

只愿长相守 提交于 2020-01-20 06:41:29
问题 I am trying to Rewrite my mode using this info[copy from a website], but it's not working .. what's wrong with it and plz give a correct answer.. The Apache rewrite engine is mainly used to turn dynamic url’s such as www.yoursite.com/product.php?id=123 into static and user friendly url’s such as www.yoursite.com/product/123 RewriteEngine on RewriteRule ^product/([^/.]+)/?$ product.php?id=$1 [L] Another example, rewrite from: www.yoursite.com/script.php?product=123 to www.yoursite.com/cat

Replacing a querystring parameter value using mod_rewrite

时间秒杀一切 提交于 2020-01-20 05:09:07
问题 I would like to map this: http://www.example.com/index.php?param1=value1&param2=value2&param3=value3 (etc. ad infinitum) to http://www.example.com/index.php?param1=newvalue1&param2=value2&param3=value3 (etc.) In other words, just change the value of a single parameter in the query string. I know what the old value is, so I am trying to match the exact text index.php?param1=value1 and replace it with index.php?param1=newvalue1 . I cannot seem to find any examples on how to do this using mod

Removing GET parameter in .htaccess

懵懂的女人 提交于 2020-01-19 17:35:39
问题 I'm not able to remove one GET parameter wrongly added by one 404 SEF module. I want to remove "task=view" only if it appears alone and not with another parameter. So www.mysite.com/1.html?task=view should be redirected to www.mysite.com/1.html . While www.mysite.com?task=view&view=article should remain unchanged. No matter which RewriteRule I use, this paramater does not go. Looks like it is being generated from any environment variable when index.php is run. For example this does not work: