Add trailing slash after removing .html extention
-
My website is non www ,it has wordpress in subdirectory and some static webpages in the root and other subdirectory
1. i want to remove .html extention from the webpages in the root and
the others static webpages in subdirectory.
2. add slash at the end.
3. 301 redirect from non slash to url with slash.so it should be
http://ghadaalsaman.com/articles.html to http://ghadaalsaman.com/articles/
and
http://ghadaalsaman.com/en/poem-list.html to http://ghadaalsaman.com/en/poem-list/
the below code
1. working with non slash at the end
**2. **redirect 301 url with slash to non
here's my .htaccess
<ifmodule mod_rewrite.c="">Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /</ifmodule>#removing trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L]#www to non
RewriteCond %{HTTP_HOST} ^www.(([a-z0-9_]+.)?domain.com)$ [NC]
RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]#html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.html [NC,L]#index redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/
RewriteRule ^index.html$ http://ghadaalsaman.com/ [R=301,L]
RewriteCond %{THE_REQUEST} .html
RewriteRule ^(.*).html$ /$1 [R=301,L]PS everything is ok with the wordpress , the problems with static pages only.
Thanks in advanced
-
Not Working
-
Can you please try the above but delete:
#removing trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L]Let me know if that works.
-
i tried that code and not working
<ifmodule mod_rewrite.c="">
Options +FollowSymLinks -MultiViewsRewriteEngine On
RewriteBase /</ifmodule>#removing trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L]#www to non
RewriteCond %{HTTP_HOST} ^www.(([a-z0-9_]+.)?domain.com)$ [NC]
RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]#html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.html [NC,L]#index redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/
RewriteRule ^index.html$ http://ghadaalsaman.com/ [R=301,L]
RewriteCond %{THE_REQUEST} .html
RewriteRule ^(.*).html$ /$1 [R=301,L]#moz
RewriteRule ^(.*)$ http://ghadaalsaman.com.com/$1/ [L,R=301] -
Hi Uber_,
Typically this is handled is by adding the following to your .htaccess file:
RewriteCond %{REQUEST_FILENAME} !-f <--looks like your version of this would also work fine. RewriteCond %{REQUEST_URI} !index.php <---This is very optional. If there are any .php files you don't want to be rewritten add their .endpath here. RewriteCond %{REQUEST_URI} !(.*)/$ <----Looks like you have this, which determines which url doesn't have a trailing slash. RewriteRule ^(.*)$ http://ghadaalsaman.com.com/$1/ [L,R=301] <----This would add a trailing slash and then redirect to the new URL. Highly recommend you add the last line because both of your / and non / ending urls are populating (which could cause duplicate content issues). This will also help with allocating proper page authority. Hope this helps, B
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
-
Removed Product page on our website, what to do
We just removed an entire product category on our website, (product pages still exist, but will be removed soon as well) Should we be setting up re-directs, or can we simply delete this category and product
Technical SEO | | DutchG
pages and do nothing? We just received this in Google Webmasters tools: Google detected a significant increase in the number of URLs that return a 404 (Page Not Found) error. We have not updated the sitemap yet...Would this be enough to do or should we do more? You can view our website here: http://tinyurl.com/6la8 We removed the entire "Spring Planted Category"0 -
Removal of date archive pages on the blog
I'm currently building a site which currently has an archive of blog posts by month/year but from a design perspective would rather not have these on the new website. Is the correct practice to 301 these to the main blog index page? Allow them to 404? Or actually to keep them after all. Many thanks in advance Andrew
Technical SEO | | AndieF0 -
How best to deal with www.home.com and www.home.com/index.html
Firstly, this is for an .asp site - and all my usual ways of fixing this (e.g. via htaccess) don't seem to work. I'm working on a site which has www.home.com and www.home.com/index.html - both URL's resolve to the same page/content. If I simply drop a rel canonical into the page, will this solve my dupe content woes? The canonical tag would then appear in both www.home.com and www.home.com/index.html cases. If the above is Ok, which version should I be going with? - or - Thanks in advance folks,
Technical SEO | | Creatomatic
James @ Creatomatic0 -
Duplicate content issue with trailing / ?
Hi ,I did a SEOmoz Crawl Test and found most pages show twice, for example: A: www.website.com/index.php/dog/walk B: www.website.com/index.php/dog/walk/ I've checked Google Analytics and 90% of organic search traffic arrives on the URLs with the trailing slash (B). Question 1: Can I assume I've a duplicate content problem? Question 2: Is it best to do 301 redirects from the 'non trailing slash' pages to the 'trailing slash pages'? Question 3: For some reason every web page has a '/index.php' in it (see A&B) above. No idea why. Should it be a SEO concern? Kind regards and thank you in advance Nigel
Technical SEO | | Richard5550 -
I have been Hit with UNWANTED Links and I need to know how to remove them?
I have been looking at Google Webmasters Tools and saw that suddenly I have this huge amount of links form an unknown source “SiteLoki” never heard of it? Didn’t want it! Need to get rid of it!
Technical SEO | | rdominey
My Website www.getyourphotosoncanvas.com experienced a sudden and dramatic loss of presence on Google about three weeks ago. I first thought it was something to do with the new Google Algorithm. I also contacted Google to be re-evaluated. They replied:
Reconsideration request for http://www.getyourphotosoncanvas.com/: No manual spam actions foundMay 10, 2012 Dear site owner or webmaster of http://www.getyourphotosoncanvas.com/,
We received a request from a site owner to reconsider http://www.getyourphotosoncanvas.com/ for compliance with Google's Webmaster Guidelines. - - - - - -
We reviewed your site and found no manual actions by the webspam team that might affect your site's ranking in Google. There's no need to file a reconsideration request for your site, because any ranking issues you may be experiencing are not related to a manual action taken by the webspam team.
Google Search Quality Team I have ran all kinds of web crawl tests, Google webmaster, talked with SEO “Experts” and still can not figure out what is happening. I decided to use a couple of SEOmoz tools to try to help me explain what is happening. I figured that if I could take a very specific and unique KeyPhrase and run it on a specific page that I might be able to better explain what is happening. Basically, We appear to be no longer searchable by key words or phrases on google?
There was another post regarding canonical tag issues; resolved, I removed all canonical tags for now. Today I discovered the links and I suspect that having even
1 link for this website will penalize you in Google. Here are some Webmaster Tools pages for reference: I also noted that the image for the link is from an old site hosted on www.Globat.com. I don't know what that significance might be. I left them in January. Thanks in advance for any help and advice you can offer, Ray Webmaster-Tools-Query_Your-Photo-On-Canvas.jpg Webmaster-Tools-Query_Photo-On-Canvas.jpg Webmaster-Tools-Query_Photos-On-Canvas.jpg Webmaster-Tools-Links_siteloki.jpg Webmaster-Tools-Links_siteloki_links.jpg0 -
Remove Bad Links Or Build New
Hello, After deeply assessing our back links we have come to the conclusion that we have too many links that have been devalued and also some spammy looking links.... Our next question is do we remove these bad links and start a fresh or do we just build new white hat links?? Thanks, Scott
Technical SEO | | ScottBaxterWW0 -
Removing robots.txt on WordPress site problem
Hi..am a little confused since I ticked the box in WordPress to allow search engines to now crawl my site (previously asked for them not to) but Google webmaster tools is telling me I still have robots.txt blocking them so am unable to submit the sitemap. Checked source code and the robots instruction has gone so a little lost. Any ideas please?
Technical SEO | | Wallander0 -
On Page 301 redirect for html pages
For php pages youve got Header( "HTTP/1.1 301 Moved Permanently" );
Technical SEO | | shupester
Header( "Location: http://www.example.com" );
?> Is there anything for html pages? Other then Or is placing this code redirect 301 /old/old.htm http://www.you.com/new.php in the .htaccess the only way to properly 301 redirect html pages? Thanks!0