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
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
-
Last Part Breadcrumb Trail Active or Non-Active
Breadcrumbs have been debated quite a bit in the past. Some claim that the last part of the breadcrumb trail should be non-active to inform users they have reached the end. In other words, Do not link the current page to itself. On the other hand, that portion of the breadcrumb would won't be displayed in the SERPS and if it was may lead to a higher CTR. Foe example: www.website.com/fans/panasonic-modelnumber panasonic-modelnumber would not be active as part of the breadcrumb. What is your take?
Technical SEO | | CallMeNicholi0 -
Rankings after manual penalty removal
I've just started working on a ecommerce website that was hit by Penguin 2.0 in May (It was ranking 2nd for it's major keyword at the time) and it hasn't been indexing for that keyword since After a lot of link removal, the reconsideration request was accepted and the manual penalty had been removed. Rankings haven't really improved and that specific keyword has not been reindexed The site does have a lot of not found errors (It was 5.5k but recently taken down to 4k) but it was still ranking before the penalty. Is there anything you believe I'm missing? Is it the onsite errors that are flagging the site as unreliable? I thought it would still appear for the keyword if that was the case
Technical SEO | | Sandeep_Matharu0 -
Website Redesign / Switching CMS / .aspx and .html extensions question
Hello everyone, We're currently preparing a website redesign for one of our important websites. It is our most important website, having good rankings and a lot of visitors from Search Engines, so we want to be really careful with the redesign. Our strategy is to keep as much in place as possible. At first, we are only changing the styling of the website, we will keep the content, the structure, and as much as URLs the same as possible. However, we are switching from a custom build CMS system which created URLs like www.homepage.com/default-en.aspx
Technical SEO | | NielsB
No we would like to keep this URL the same , but our new CMS system does not support this kind of URLs. The same with for instance the URL: www.homepage.com/products.html
We're not able to recreate this URL in our new CMS. What would be the best strategy for SEO? Keep the URLs like this:
www.homepage.com/default-en
www.homepage.com/products Or doesn't it really matter, since Google we view these as completely different URLs? And, what would the impact of this changes in URLs be? Thanks a lot in advance! Best Regards, Jorg1 -
Removing images from site and Image Sitemap SEO advice
Hello again, I have received an update request where they want me to remove images from this site (as of now its a bunch of thumbnails) current page design: http://1stimpressions.com/portfolio/car-wraps/ and turn it into a new design which utilized a slider (such as this): http://1stimpressions.com/portfolio/ They don't want the thumbnails on the page anymore. My question is since my site has a image sitemap that has been indexed will removing all the images hurt my SEO greatly? What would the recommended steps to take to reduce any SEO damage be, if so? Thank you again for your help, always great and very helpful feedback! 🙂 cheers!
Technical SEO | | allstatetransmission0 -
Webmaster > HTML Improvements > Duplicate title tags
Hi, Webmaster > HTML Improvements > Duplicate title tags shows as in screenshot. How can i set this right as its a single page which duplicates? http://imgur.com/mjB0xZS Regards
Technical SEO | | mtthompsons0 -
.html extension
My new client's original web developer set up many pages with .html extensions. My plan is to turn most of these into php pages. Also, I think the .html extension displaying in the browser is just ugly so I want to drop the .html extension from those pages that remain. I know how to do this with .htaccess, but my question is should I 301 redirect all the .html pages to the page without an extension. (For example, should I redirect www.example.com/page.html to www.example.com/page) I don't know how many, in any, links there are out there to these pages, but I'm guessing not many. I'm sure it's not that big a deal but I was wondering if it would be worth the time to do that for the pages I change.
Technical SEO | | Mattymar0 -
Benefits to having an HTML sitemap?
We are currently migrating our site to a new CMS and in part of this migration I'm getting push-back from my development team regarding the HTML sitemap. We have a very large news site with 10s of thousands of pages. We currently have an HTML sitemap that greatly helps with distributing PR to article pages, but is not geared towards the user. The dev team doesn't see the benefit to recreating the HTML sitemap despite my assurance that we don't want to lose all these internal links since removing 1000s of links could have a negative impact on our Domain Authority. Should I give in and concede the HTML sitemap since we have an XML one? Or am I right that we don't want to get rid of it?
Technical SEO | | BostonWright0 -
Directory Indexed in Google, that I dont want, How to remove?
Hi One of my own websites, having a slight issue, Google have indexed over 500+ pages and files from a template directory from my eCommerce website. In google webmaster tools, getting over 580 crawl errors mostly these ones below I went into my robots text file and added Disallow: /skins*
Technical SEO | | rfksolutionsltd
Disallow: /skin1* Will this block Google from searching them again? and how do I go about getting the 500 pages that are already indexed taken out? Any help would be great | http://www.rfkprintsolutions.co.uk/skin1/modules/Subscriptions/subscription_priceincart.tpl | 403 error | Jan 15, 2012 |
| http://www.rfkprintsolutions.co.uk/skin1/modules/Subscriptions/subscription_info_inlist.tpl | 403 error | Jan 15, 2012 |
| http://www.rfkprintsolutions.co.uk/skin1/modules/Subscriptions/subscriptions_admin.tpl | 403 error | Jan 15, 2012 |0