.htaccess problem using POST method
-
Hi guys
I'm after some help with trying to achieve the following:
1. Canonicalise to http://www.
2. Remove the index.php from root and subfolders.
I have the .htaccess code below, which seemed to work fine, but the urls use the POST method and this isn't working with the rewrites.
Can anyone please advise as to what I am doing wrong? As you can probably guess .htaccess isn't my strongest SEO discipline!
The code I have is:
http:// to http://www.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomainexample.com
RewriteRule (.*) http://www.mydomainexample.com/$1 [R=301,L]/index.php to /
Options +FollowSymLinks
DirectoryIndex index.phpRewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php\ HTTP/
RewriteRule ^index.php$ http://www.mydomainexample.com/ [R=301,L]Subdirectory /index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)index.(php|html|htm?)[#?]?
RewriteRule ^(([^/]+/))index.(php|html|htm?)$ http://www.mydomainexample.com/$1 [R=301,L]Just to add to this I have found this which I think is what I need to restrict it to GET:
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L] Thank you in advance for any suggestions as to how I may put this code together..
Trevor
-
Hi Keri
Thanks for the thumbs up
Must be a lot of people out there with the same question; the post on this topic, on my site, gets a lot of visitors.
Thanks again.
-
I gave you a thumbs up! Glad you solved this, and I'm sure it'll help someone in the future. Thanks for posting the answer!
-
Hi guys
Not sure if I can get mozpoints for answering my own question - perhaps someone can thumb it up
Anyway below is the .htaccess code that seems to work for canonicalization and allowing POST:
http:// to http://www.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomainexample.com
RewriteRule (.*) http://www.mydomainexample.com/$1 [R=301,L]REDIRECT /folder/index.php to /folder/
RewriteCond %{THE_REQUEST} ^GET.index.php\ HTTP/
RewriteRule ^(([^/]+/))index.php$ http://www.mydomainexample.com/$1 [R=301,L]Cheers
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Indexation and visibility problem
Hi I am working on a website (usarrestsearch org) for 6 months. I wrote about 100 pages full of good content. for some reason I see only 75% of the pages indexed in GWT. and Im having problems with SERP positions not rising. I suspect that it might be connected to the structure of the site. will appreciate any help thanks
Technical SEO | | holdportals0 -
Do I have a robots.txt problem?
I have the little yellow exclamation point under my robots.txt fetch as you can see here- http://imgur.com/wuWdtvO This version shows no errors or warnings- http://imgur.com/uqbmbug Under the tester I can currently see the latest version. This site hasn't changed URLs recently, and we haven't made any changes to the robots.txt file for two years. This problem just started in the last month. Should I worry?
Technical SEO | | EcommerceSite0 -
Should I use canonicals? Best practice?
Hi there, I've been working on a pretty dated site. The product pages have tabs that separate the product information, e.g., a tab for specifications, a tab for system essentials, an overview tab that is actually just a copy of the product page. Each tab is actually a link to a completely separate page, so product/main-page is split into product/main-page/specs, product/main-page/resources, etc. Wondering if canonicals would be appropriate in this situation? The information isn't necessarily duplicate (except for the overview tabs) but with each tab as a separate page, I would imagine that's diluting the value of the main page? The information all belongs to the main page, shouldn't it be saying "I'm a version of the main page"?
Technical SEO | | anneoaks0 -
.htaccess: Multiple URLs catches filename
Hi, I have the following line in my .htaccess:
Technical SEO | | rasmusbang
RewriteRule privacy stdpage.php?slug=privacy [L] So if you go to the www.mysite.com/privacy it takes the stdpage.php with the argument above. But if you go to www.mysite.com/privacysssssssss catches the same file. How can I prevent this? It will give me multiple URLs with the exact same content. I have a 404 page which i would like to show instead when the match is not 100%. -Rasmus0 -
is pointing to the same page that it is already on, is this a problem?
So we have a wordpress site with the all-in-one-seo-pack installed. I have just noticed in our crawl diagnostics that a canonical tag has been put in place on every single one of our pages, but they are all pointing to the pages that they are already on. Is this a problem? Should I be worried about this and delve more deeply to figure out as to why this has happened and get it removed? Thanks
Technical SEO | | cttgroup0 -
Htaccess redirect with question mark
Hi I have a problem setting up my htaccess for a specific page that has a question mark in the link, and one that has a space in the link and also a question mark. So I would like 2 redirects in my htaccess like that: www.olddomain.com/page.php?page=pagename1 to www.newdomain.com/newpage1.html www.olddomain.com/page.php?page=page name2 to www.newdomain.com/newpage2.html I have tried with something like this but doesn't work: RewriteEngine on RewriteRule ^page.php?page=pagename1 "http://www.newdomain.com/newpage1.html" [R=301,L] RewriteRule ^page.php?page=page name2 "http://www.newdomain.com/newpage2.html" [R=301,L] Could someone tell me what exactly I have to change? Thanks
Technical SEO | | darkanweb0 -
Is it better to guest post with or without using rel=author?
If I guest post on 50 blogs, all using rel=author so they are attributed to my Google Plus account, would the links be de-valued since they are self reference back to my own blog/website? Would it be better to guest post on a blog that doesn't use rel=author?
Technical SEO | | designquotes0 -
Video Link Bait - Protections, Formats, Methods
I wanted to find out if anyone could recommend the best technique for protecting a video on a website. We have been able to secure a private interview with one of the largest manufacturers in this customers industry. Unfortunately the interview was done impromptu with an iphone, but the recording is not too bad. The volume is low, but we will also type out the content of the interview on our blog, right beneath where the video is posted for viewing. We were hoping to only post this video on our blog, so that people within our industry will link to that page, increasing our link power. But we wanted to make sure that people couldn't steal the video and post it in other places to avoid giving us our link. What is the best method for accomplishing this? What video format would be ideal to hopefully accommodate windows, mac, IE, Firefox, Safari, mobile phones, ipads etc.? Are we on the right track on how to most effectively use this video for our own benefit?
Technical SEO | | JerDoggMckoy0