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
-
Website homepage temporarily getting removed from google index
hi, website: www.snackmagic.com The home page goes out of google index for some hours and then comes back. We are not sure why our home page is getting de-indexed temporarily. This doesn't happen with other pages on our website. This has been happening intermittently in the gap of 2-3 days. Any inputs will be very useful for us to debug this issue Thanks
Technical SEO | | manikbystadium0 -
Removing site subdomains from Google search
Hi everyone, I hope you are having a good week? My website has several subdomains that I had shut down some time back and pages on these subdomains are still appearing in the Google search result pages. I want all the URLs from these subdomains to stop appearing in the Google search result pages and I was hoping to see if anyone can help me with this. The subdomains are no longer under my control as I don't have web hosting for these sites (so these subdomain sites just show a default hosting server page). Because of this, I cannot verify these in search console and submit a url/site removal request to Google. In total, there are about 70 pages from these subdomains showing up in Google at the moment and I'm concerned in case these pages have any negative impacts on my SEO. Thanks for taking the time to read my post.
Technical SEO | | QuantumWeb620 -
What to do about removing pages for the 'offseason' (IE the same URL will be brought back in 6-7 months)?
I manage a site for an event that runs annually, and now that the event has concluded we would like to remove some of the pages (schedule, event info, TV schedule, etc.) that won't be relevant again until next year's event. That said, if we simply remove those pages from the web, I'm afraid that we'll lose out on valuable backlinks that already exist, and when those pages return they will have the same URLs as before. Is there a best course of action here? Should I redirect the removed pages to the homepage for the time being using a 302? Is there any risk there if the 'temporary' period is ~7 months? Thanks in advance.
Technical SEO | | KTY550 -
Site dropped after I removed spammy KW-stuffed section from homepage
An SEO newbie. I took a sabbatical from my site for 10 months for personal reasons & I'm now coming back to it for the first time and facing a number of issues that I'd appreciate some advice on. 1) In the past week, my rankings for my main keywords have suddenly plummeted from ~#7 - #8 to about #25. The only thing I've done in that time is sign up for Google Webmaster Tools and clean up a spammy-looking keyword-stuffed section at the foot of my homepage. (It read: Red keyword | blue keyword | green keyword | yellow keyword ... 20 times). I've kept the links (to internal pages of my site) but removed keywords. I've no social presence whatsoever. No Twitter, Facebook, Digg, G+, Google Places, nothing -- but I can't imagine this is behind the sudden drop. 2) Last year my rankings start to fall in late April. But for the first two months or so the drop was only from #1 to #2 - #3. I put it down to Penguin as my backlink profile is not ideal. About 5 years ago some SEO got me a mass of sitewide blog footer links with exact-match anchors -- some of which still remain. (Some domains have 750-plus links pointing back to my site). I've a sitewide banner (2,500 pages) on a site with a related theme to mine. I've loads of links from article directory sites (from when I knew no better). * Question: In Google Webmaster Tools I have not (yet?) received an unnatural links warning. Should I still clean up the links with the Link Disavow tool?
Technical SEO | | Jeepster0 -
Remove more than 1000 crawl errors from GWT in one day?
In google webmasters tools you have the feature "Crawl Errors". This one displays the top 1000 crawl errors google have on your site. I have around 16k crawl errors at the moment, which all are fixed. But i can only mark 1000 of them as fixed each day/each time google crawls the site. (This as it only displays top 1000 errors. When i have marked those as fixed it won't show other errors for a while.) Does anyone know if it's possible to mark ALL errors as fixed in one operation?
Technical SEO | | Host10 -
Duplicate content issue. Delete index.html and replace with www.?
I have a duplicate content issue. On my site the home button goes to the index.html and not the www. If I change it to the www will it impact my SERPS? I don't think anyone links to the index.html.
Technical SEO | | bronxpad1 -
Do trailing / in URLs matter?
I was wondering if search engines see duplicate content on two different URLs if the content is available via www.xyz.com/services or www.xyz,com/services/
Technical SEO | | TheOceanAgency0