When I go to http://sweatingthebigstuff.com/lending-club-loans-to-avoid/, I get a 404 page. But when I hit backspace twice, it deletes the / but not the d so there's a hidden space there. Once I delete it, it works.
How is there a hidden space in my URL and can I do something to detect and delete it in the .htaccess file? Otherwise every redirection I add has to be one of each.
EDIT:
Here's what I think may be relevant from the .htaccess file:
RewriteCond %{REQUEST_URI} !\.[^./]+$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://sweatingthebigstuff.com/$1/ [R=301,L]
RedirectMatch 301 ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+)$ /$1
It actually looks like this: http://sweatingthebigstuff.com%E2%80%8B/lending-club-loans-to-avoid%E2%80%8B/
Try changing
RewriteCond %{REQUEST_URI} !\.[^./]+$
RewriteCond %{REQUEST_URI} !(.*)/$
to
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Related
I've been trying for days to generate a file that modifies the url structure.
I have a current url like this
http://localhost/stores/leo
and I need it to stay like this
https://leo.localhost
Use PHP Server XAMP and Larabel
the word "leo" is generated according to the product and it will always change.
How could you generate it?
Thanks!
I have this code that works but the URL changes in the address bar and does not stay with the desired URL.
RewriteEngine On
RewriteBase /
#force https and non-www
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
# profile redirection
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(.*)\.localhost [NC]
RewriteRule (.*) https://localhost/stores/%1/$1 [L]
I have this in my .htaccess file:
# For Friendly URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
I want to redirect the url /sale to the new one /gift-sales So I have added this to the above:
RewriteCond %(THE-REQUEST)^sale$
RewriteRule ^(.*)$ /gift-sales [R=30,L]
In the ModX backend I have, of course, changed the alias to gift-sales, but I cannot seem to get the redirect working. Can anyone point me in the right direction?
try this:
RewriteRule ^/sale http://www.mydomain.com/gift-sales [R=301,L]
I would like to remove the filename from a "subdirectory" URL and just display the subdirectory in the browser URL.
So:
www.domain.com.au/login/public_index.php
becomes:
www.domain.com.au/login/
I have tried various solutions from this site and the internet, but none have worked.
If possible I would like to put the new redirection in the root htaccess file?? and not in the subdirectory htaccess file?
* Just in case other redirections in the htaccess file are in conflict with any new subdirectory redirections, here are the other (and necessary) redirections in the htaccess file that perform important jobs:
#(1) A redirection to remove root level index.php from the url
# Redirect index.php to domain.com.au
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.domain.com.au/ [R=301,L]
#(2)
# Redirect domain.com.au to www.domain.com,au
RewriteCond %{HTTP_HOST} ^domain.com.au [NC]
RewriteRule ^(.*)$ http://domain.com.au/$1 [L,R=301]
#(3)
# Force SSL on login directory
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} login
RewriteRule ^(.*)$ https://www.domain.com.au/$1 [R,L]
Any help would be appreciated as all solutions to add the new subdirectory URL redirect thus far have failed.
Regards,
Peter
You can do something similar to what you did in #(1):
#(4)
# remove public_index.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+)/public_index\.php\ HTTP/
RewriteRule public_index\.php$ http://www.domain.com.au/%1/ [R=301,L]
# internally add it back
RewriteCond %{REQUEST_URI} ^/([^/]+)/?$
RewriteCond %{DOCUMENT_ROOT}/%1/public_index.php -f
RewriteRule ^ /%1/public_index.php [L]
That's for any subdirectory, but if you're only interested in login, that gets easier:
#(4)
# remove public_index.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /login/public_index\.php\ HTTP/
RewriteRule public_index\.php$ https://www.domain.com.au/login/ [R=301,L]
RewriteRule ^/?login/?$ /login/public_index.php [L]
I'm using mod_rewrite to redirect on URLs like: mysite.com/123
RewriteEngine On
RewriteRule ^([0-9]+)$ /n/index.php?id=$1 [L]
This works only for numeric IDs.
How do I make it work for non-numeric IDs while I preventing the redirect from happening when a subdirectory is found?
Change the rewrite rules to this: This should work for both numeric as well as non-numeric IDs preventing the redirect from happening when a subdirectory is found.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([\w\d]+)$ /n/index.php?id=$1 [L]
When visitors go, to say,:
http://website.com/dir/dir2/file.html
My re-write clears the path beyond the base url and redirects them to the home page with www. in the front:
http://www.website.com/
How can I prevent the stripping from occurring and sending visitors to the homepage instead of their requested url? FYI, the URLs in question DO exist.
Thanx!
Include the file/path info on the end of the rewrite like this:
RewriteCond %{HTTP_HOST} !^www\.website\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.website.com/$1 [L,R]
FYI, this is for a Magento site.
In .htaccess, after
#RewriteBase /magento/
After it I placed on their own lines:
RewriteCond %{HTTP_HOST} !^www\.website\.com$ [NC]
RewriteRule ^(.*)$ http://www.website.com/$1 [L,R=301]
And it works. Dad with kids also had it right, just don't know what the second line was for.
Most people need RewriteBase set, so try:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^(?:www\.your-live-domain\.com|staging\.domain\.com)$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule .* http://www.your-live-domain.com/$0 [L,R=301]
Use 301 to make it permanent