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
-
Google confused by trailing slash
My client has a page with the URL https://www.corptexsystems.ca/training/. Google won't index this page because it has detected a canonical at https://www.corptexsystems.ca/training (without the trailing slash). I can't find https://www.corptexsystems.ca/training without the trailing slash anywhere in our site. All the other page URLs end with the slash. How do I sort this out and convince Google that https://www.corptexsystems.ca/training/ is the version to index? Thanks in advance for your help, SEO masters! -AK
Technical SEO | | AndyKubrin0 -
Can bad html code hurt your website from ranking ?
Hello,For example if I search for “ Bike Tours in France” I am looking for a page with a list of tours in France.Does it mean that if my html doesn’t have list * in the code but only that apparently doesn’t have any semantic meaning for a search engine my page won’t rank because of that ?Example on this page : https://bit.ly/2C6hGUn According to W3schools: "A semantic element clearly describes its meaning to both the browser and the developer. Examples of non-semantic elements: <div> and - Tells nothing about its content. Examples of semanticelements: <form>, , and- Clearly defines its content."Has anyone any experience with something similar ?Thank you, </form>
Technical SEO | | seoanalytics0 -
Remove page with PA of 69 and 300 root domain links?
Hi We have a few pages within our website which were at one time a focus for us, but due to developing the other areas of the website, they are now defunct (better content elsewhere) and in some ways slightly duplicate so we're merging two areas into one. We have removed the links to the main hub page from our navigation, and were going to 301 this main page to the main hub page of the section which replaces it. However I've just noticed the page due to be removed has a PA of 69 and 15,000 incoming links from 300 root domains. So not bad! It's actually stronger than the page we are 301'ing it to (but not really an option to swap as the URL structure will look messy) With this in mind, is the strategy to redirect still the best or should we keep the page and turn it into a landing page, with links off to the other section? It just feels as though we would be doing this just for the sake of google, im not sure how much decent content we could put on it as we've already done that on the destination page. The incoming links to that page will still be relevant to the new section (they are both v similar hence the merging) Any suggestions welcome, thanks
Technical SEO | | benseb0 -
Should I Remove Thousands of Bad Links over a Short Time or Long Time?
Hey Moz Community! I've got a website that has hundreds of thousands of old links that don't really offer any great content. They need to be removed. Would it be a better idea to remove them in batches of 5000,10000, or more over a long time... or remove them all at the same time because it doesn't matter? Cheers, Alex
Technical SEO | | Anti-Alex0 -
Keyword place in page HTML code? Higher is better?
Hello, is it important to place keyword more higher in html code Our situation: item page. H1 and all text about this item with keyword mentioned three times is in the end of html code? Competitors pages with info about item, but higher keyword place and description in html code make better in SERPS. Could it be reason? Could we change place of text about item in html code ? Giedrius, Lithuania
Technical SEO | | Patogupirkti0 -
Noindex vs. page removal - Panda recovery
I'm wondering whether there is a consensus within the SEO community as to whether noindexing pages vs. actually removing pages is different from Google Pandas perspective?Does noindexing pages have less value when removing poor quality content than physically removing ie. either 301ing or 404ing the page being removed and removing the links to it from the site? I presume that removing pages has a positive impact on the amount of link juice that gets to some of the remaining pages deeper into the site, but I also presume this doesn't have any direct impact on the Panda algorithm? Thanks very much in advance for your thoughts, and corrections on my assumptions 🙂
Technical SEO | | agencycentral0 -
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 -
Micro formats to block HTML text portions of pages
I have a client that wants to use micro formatting to keep a portion of their page (the disclaimer) from being read by the search engines. They want to do this because it will help with their keyword density on the rest of the page and block the “bad keywords” that come from their legally required disclaimer. We have suggested alternate methods to resolve this problem, but they do not want to implement those, they just want a POV from us explaining how this micro formatting process will work. And that’s where the problem is. I’ve never heard of this use case and can’t seem to find anyone who has. I'm posting the question to the Moz Community to see if anyone knows how microformats can keep copy from being crawled by the bots. Please include any links to sites that you know that are using micro formatting in this way. Have you implemented it and seen results? Do you know of a website that is using it now? We're looking for use cases please!
Technical SEO | | Merkle-Impaqt0