All Questions
Tagged with trailing-slash htaccess
13 questions
0
votes
0
answers
206
views
Run .htaccess rule to remove trailing slash only if such a file exists
I have the following .htaccess rule but I would only like it to run it if a file exists without the removed trailing slash:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
I use ...
1
vote
1
answer
2k
views
Remove PHP extension from URLs such that the URLs work with or without a trailing slash
My directory structure is
- Assets
- Dashboard
- index.php
- account.php
index.php
about.php
verify.php
What I basically want it to be:
Remove the .php extension for example http://example.org/...
1
vote
1
answer
270
views
How to add trailing slashes to links in my pages from .htaccess in addition to the redirects I've implemented?
I've recently appended the trailing slash at the end of the URL by using this .htaccess code:
#add trailing slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^...
-1
votes
1
answer
4k
views
How to remove trailing slash from my root URL in htaccess?
I've tried several ways to remove the trailing slash from my URL in .htaccess and nothing worked but now even my URL can't be found because now it has a slash.
Here is what my .htaccess looks like. I ...
1
vote
2
answers
1k
views
Forcing trailing slash at end of "fake" folders
The working codes that I've found here most put a slash in everything.
I just need force trailing slash in these "fake dirs" (that are part of my rewriting scheme (only directories)) and keep ...
4
votes
2
answers
4k
views
Redirect URL with multiple trailing dots and trailing slashes using .htaccess
I need to fire 301 redirection
from example.com... to example.com
and example.com////// to example.com
Here is my code:
RewriteCond %{THE_REQUEST} \ /([^\?\ .]*)\.(?:\?|\ |$)
RewriteRule ^ /%1 [L,R=...
5
votes
1
answer
4k
views
Trailing slash, google search console and sitemap
I force usage of trailing slash for all of my pages under https://example.com, however the main domain remains without it - from what I've read it's OK to do so, but I'm not sure how does Google '...
3
votes
1
answer
2k
views
How to remove trailing slashes from URL with .htaccess in localhost?
Here is my localhost folder structure:
•www (wamphost folder)
•example.com (folder)
•index.php
With the current the URL results:
localhost/example.com/
The URL I would like is:
...
1
vote
1
answer
226
views
How to remove a slash with .htaccess
I have a problem, when I'm on the homepage and want to go to a page, it says this:
continenten/.html on this server
How can I remove the / so it's continenten.html and not continenten/.html?
This ...
1
vote
1
answer
3k
views
Using htaccess to internally and externally redirect a page at the same time [duplicate]
I've been trying to figure this out for two hours, and I give up. I want to externally redirect about.php to about/, and also have about/ internally redirect to about.php
RewriteRule ^about/$ /test/...
9
votes
2
answers
8k
views
.htaccess redirect url without trailing slashes
In my htaccess I have some rewrited urls like these:
RewriteRule ^first-page$ /subdir/page.php?id_page=1 [QSA,L]
RewriteRule ^second-page$ /subdir/page.php?id_page=2 [QSA,L]
RewriteRule ^third-page$ /...
3
votes
2
answers
9k
views
Remove multiple trailing slashes in a single 301 in .htaccess?
There is a similar question here, but the solution does not work in Apache for our site.
I'm trying to remove multiple trailing slashes from URLs on our site. I found some .htaccess code that seems ...
8
votes
3
answers
50k
views
How to remove trailing slashes from URL with .htaccess?
The situation
Across the entire domain, we'd like the URLs to hide file extensions and remove trailing slashes, independent of the domain name itself (as in, works on any domain).
Sample of our ...