Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
Can someone interpret what this .htaccess means? Thanks!
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^abcdef\.com$
RewriteRule (.*) http://abcdef.com/$1 [R=301,L]
It's a redirect for URIs beginning with www (or any other subdomain).
The Rewrite says:
If the address the browser is pointing at doesn't begin with abcdef.com, then drop the preceding subdomain.
So if you point the browser at:
http://www.abcdef.com/homepage/
the server will redirect the browser to:
http://abcdef.com/homepage/
If the server has been accessed via a domain other than abcdef.com, redirect to abcdef.com with a 301 status code (permanent) and append anything that came after it, so mysite.com/contact.htm or even sub.abcdef.com/contact.htm would become abcdef.com/contact.htm. Could be used on a server hosting multiple domains which should all run from a single main domain, or a site owner has renamed their domain and wants their old links to carry over to the new website.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
For SEO and usability purposes you may want to redirect your visitors to open your site only through http://www.yourdomain.com
how to redirect throught www.
For SEO and usability purposes you may want to redirect your visitors to open your site only through http://www.yourdomain.com.
Some applications, including Magento, however, require additional modifications to make this redirection work properly.
First, you should open the .htaccess file in the Magento folder. In it locate the "RewriteEngine on" line and right after it add the following lines:
RewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
Once you do this, save the .htaccess file and log in to the administrative end of Magento.
Then go to the System > Configuration menu and from the left panel click the "Web" button.
Unfold the "Unsecured" set of options and change the "Base URL" option from http://yourdomain.com to http://www.yourdomain.com.
Save the changes and your Magento website will be running with www.yourdomain.com only!
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I can't seem to find an answer to this specific question so sorry if it's answered.
Here's the redirect we have in .htaccess
Redirect 301 /product-name /products/product-name/
Problem:
If the www is left off then the redirect changes the path and no longer works. e.g. if this is entered into the browser window:
domain.com/product-name
Then the redirect creates this url in the browser window which obviously doesn't go anywhere:
www.domain.comproduct-name
Not sure what I'm doing wrong sorry - I should also mention that we have a non-www redirect at the bottom of the virtual host file like this:
<VirtualHost *:80>
ServerName domain.com
Redirect permanent / http://www.domain.com
</VirtualHost>
Add a / after .com in your redirect from non-www to www:
Redirect permanent / http://www.domain.com/
You need to add a trailing / in your Redirect rule:
Redirect permanent / http://www.domain.com/
The documentation for that directive states:
Additional path information beyond the matched URL-path will be appended to the target URL.
The matched URL-path is /, so anything "beyond" that will be appended. In http://domain.com/product-name, the part beyond the matched / is product-name, so appending that to http://www.domain.com (without putting a / back in) will give you http://www.domain.comproduct-name, as you observed.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have uploaded a couple of PHP testsites on my web host, but all the URLs end with a .php.
How can I convert /image.php?id=1 to yoursite.com/image/1?
How can I get the $id from yoursite.com/image/1 if a visitor manually enters the URL?
In your .htaccess file make sure you have
RewriteEngine on and do the following:
RewriteRule ^image/([0-9]+)$ image.php?id=$1 [L]
For instance:
RewriteEngine on
RewriteRule ^image/([0-9]+)$ image.php?id=$1 [L]
This is assuming you're running a webserver that can handle .htaccess - you may also need to enable mod_rewrite
Enabling this is dependent on the webserver you're running, if it's apache2 you could do
a2enmod rewrite
and service apache2 restart
in your terminal.
If you're unsure if it is enabled or not; you can do
<?php
phpinfo();
?>
and look for mod_rewrite
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've got some duplicate content and want to redirect to the right url (remove a part of the url and redirect)
Examples:
http://www.domain.com/en/url/1-url
http://www.domain.com/es/url/1-url
http://www.domain.com/fr/url/1-url
....
The individually should redirected to:
http://www.domain.com/en/url
http://www.domain.com/es/url
http://www.domain.com/fr/url
....
Because I have to do this for a lot of urls, I can't redirect them each manually and need a rule which detects if the url contains "/1-url" and if yes remove this part from the url - but only this part.
Would be great if a mod-rewrite hero can help me with this. I'm searching for solution over .htaccess via a rewrite rule.
Check this:
RewriteRule (\w{2})/([^/]+)/\d+-[^/]+$ /$1/$2 [R=301,L]
RewriteRule ([^/]+)/\d+-[^/]+$ /$1 [R=301,L]
If you use a imported file to each 1-url page only add redirect method to imported file.
For example your every 1-url page have header.php, add redirect function to header.php
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've two domains with same name but different TLD like .com and .net.
i'm using blog on ".com" domain and forum on ".net" domains like
Sites 1: "http://www.mywebsite.com/" (blog)
Site 2: "http://www.mywebsite.net/forum" (forum)
I'm facing problem with Google webmaster tool, webmaster tool trying to crawle my .com domain as forum hosted like "www.mydomain.com/forum" however forum not exist on .com domain. its exist on .net domain. so its generate 404 errors.
Please, let me know some code to to redirect ".com/forum/ {Plus Queries} /" to exact ".net/forum/{ Destination }" i believe its help to mark remove 404 errors or help to prevent more errors.
however, today I've set my robots.txt to disable Google crawling on ".com/forum"
In the htaccess file in your document root for the .com domain, add:
Redirect 301 /forum http://www.mywebsite.net/forum
If both domains share the same document root, thus sharing the same htaccess file, then you'll need to do an additional check for the host by using mod_rewrite instead of mod_alias:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com$ [NC]
RewriteRule ^/?forum/(.*)$ http://www.mywebsite.net/forum/$1 [L,R=301]