I've tried many options in .htaccess without success. What I want to do is this:
I have Wordpress residing in its own folder, like this: site.com/folder
I want all users visiting site.com to be redirected to site.com/folder/page but in such a way that the URL doesn't change in the browser. All other URLs, such as site.com/folder and site.com/folder/page1 etc shouldn't be affected.
How to do this, in as SEO-friendly way as possible?
Thanks everyone.
You can't redirect a user to a other page from serverside without to show this to the use.
But if you need, you can use the HTML tag <frame> http://www.w3schools.com/tags/tag_frame.asp
But the bad side with this is the use always will be show "site.com" and not the real page.
But I think the best way is to proxy the result, in Apache you can do this by something like this.
RewriteEngine ON
RewriteRule ^/$ folder/page/index.php [L]
Related
I would like to add some htaccess so that when a visitor goes to:
domain.com/xxx
They would see the content (without the URL changing) from
domain.com/yyy/zzz
Also any subcontent would show... like visiting
domain.com/xxx/inner-page
would show the content from:
domain.com/yyy/zzz/inner-page
I know that can be done, I just haven't figured out the htaccess code for it yet.
Here's the extra part I'm not sure can be done- sometimes those pages may have full URL links pointing to "/yyy/zzz/inner-page"
I would want anyone going to one of those pages to be redirected (changing the URL) to the equivalent "xxx" url... hopefully without causing a loop of too many redirects issue. Is that possible to do?
You may use this rule in site root .htaccess:
RewriteEngine On
RewriteRule ^xxx(/.*)?$ yyy/zzz$1 [L,NC]
I'm doing this to fix an error with my AMP pages. I'm using the Automatic AMP plugin, and this plugin lets you access the AMP pages using 2 different methods
site.com/post/amp/
site.com/post/?amp
Using the AMP Page validator (https://validator.ampproject.org) I see that all AMP pages using just /amp/ get multiple errors, while /?amp is validated correctly.
Unfortunately, Google is checking /amp/ for all my pages, hence I'm getting tons of errors.
What I'd like to know is how to use the .htaccess redirect rule to add the ? to the AMP queries so all /amp/ requests are redirected (with a 301) to /?amp/
I'd appreciate suggestions on this. Thank you
Something like this:
RewriteEngine on
RewriteRule ^(.*)/amp/$ /$1?amp [R=301,L]
This will redirect any URL ending in /amp/ to the same but with ?amp instead, which seems to be what you want. To go in your root .htaccess file.
I'd like to do the reverse of this issue. I am trying to redirect users from a subfolder to a child page. This is my current rule that doesn't work:
Redirect 302 /boston /boston/info
Using this, if I go to example.com/boston, I get redirected to example.com/boston/info/info/info/info/info/info... and it keeps going.
I imagine I'll need to switch to a RewriteRule in order to prevent this duplication. How should I go about this?
"/boston/info" - This should be the full URL you are redirecting too.
eg. www.website.com/boston/info
After you've been able to successfully create a url rewrite how do you handle the original and other possibly ways to access a page. This of course to prevent duplicate content. For example if I have this:
RewriteEngine on
RewriteBase /
RewriteRule ^blog/(\d+)/([\w\-/\.]+)/?$ blog.php?id=$1&article_title=$2 [L]
I'm able to access the page by the url
https://www.mysite.com/blog/10/mysite.com (the mysite.com is the article title)
The problem is I'm also able to access the site by going to
https://www.mysite.com/blog.php?id=10article_title=sitetitle
https://www.mysite.com/blog.php?id=10
ect.
How are you supposed to handle those particular urls.
Also should I change the blog.php?id=10 to the rewritten url? Can I rely on something else and just start using the full rewritten url now? The site is new.
For my web site, I have the script that gets called from inside the rewrite detect the URI they were fetched from (using the "REQUEST_URI" variable that at least Apache sets), and redirect to the canonical one if they ever get called with the internal one (outputting a 301 direction).
My business has been bought-out. As such we are re-branding and changing the URL's of our sites. I have 2 URL's pointing to one web server (the old, original URL and the new URL) and what I would like to do is have script on my pages to see if my user has visited the old URL. If they have I would then like them to be redirected to a particular html page to tell them that the site has changed and that they need to update their favourites. I do not want the redirect to be automated.
Basically any time the old URL is detected I would like them redirected to the redirect page to inform them
IF URL contains 'dls.myOLDwebsite.co.uk' THEN REDIRECT to: 'dls.mywebsite.co.uk/redirect.html'
The reason I would like to do this is because if the user is going to the new, correct address (example; dls.myNEWwebsite.co.uk) then I don't want any redirects or messages.
Can anyone assist?
I believe you're looking for this.
You need to add the following to the .htaccess file of your site
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REMOTE_HOST} dls.myOLDwebsite.co.uk ^
RewriteRule ^/$ http://dls.mywebsite.co.uk/redirect.html [R=301,L]