I have made an opencart store on a subdomain, and I was wondering if there is any way to redirect pages cause when I replace the store word to anything it gives me 404 eror page not found.
ex: http://XXX.XXX/store -----------> http://XXX.XXX/mobile (i got the 404 error)
And how I can get rid from the 404 error on opencart 3 store?
You can redirect like this
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.net/$1 [L,R=301,NC]
where example.com is the old domain and example.net is the new one
please share your current .htaccess file for more details
Related
Using the code below, I removed .php extensions from URLs and redirected php URLs to non-php URLs. Now I am trying to make it work with an exception. For example, I don’t want a particular page redirected. Let’s say I have a file name “file2022.php” and I don’t want it to be redirected at all. How can I do that?
RewriteEngine on
RewriteCond %{THE_REQUEST} /([^.]+).php [NC]
RewriteRule (.+) /%1 [L,R=301]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^/?(.+)/?$ /$1.php [L]
I'm working for a company and just deployed a project for them, but I encountered an issue. so, when you go to the link http://domain, you can go to the page, and from there you can go to any other page (react route), but if you go directly to http://domain/some-end-point, it shows 404 not found. does anyone know how to fix it?
That happened because your server side doesn't handle redirect to index.html, You can fix it by config your back end to always redirect to html, or simply you can fix it from react-router using HashRouter instead of BrowserRouter
here is a full explanation about Server side vs client side routing
Add the following code to the public folder file name should be
_redirects
/* /index.html 200
refer image
You can fix this with .htaccess in the root folder :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
I am using apache server for an angularJS web-app. Its purely based on AngularJS/HTML5 and has no server side programming like php or others.
When I say localhost on my browser (Chrome 49+), it takes me to http://localhost/Login/Index as per the routes defined. But when I refresh the page, browser says The requested URL /Login/Index was not found on this server.
I went through some posts on stackoverflow and tried this in my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
Options FollowSymLinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /#/$1 [L]
</IfModule>
I tried removing few lines and it shows me some error while refreshing the page. So this means that .htaccess file is being applied. So I suppose the problem must be with the RewriteRule. What should I write in the RewriteRule? Any other quick/better way to solve this problem?
I have hundreds of bad URLs. They all have a parameter in common
i.g parmameter "date"
I've tried this:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^ date=(.+?)
RewriteRule ^$ http://domain.com/404 $ [R,L]
The result was that it redirect to a non-existing page and resulted a 404 error
I've also tried
RewriteEngine On
RewriteCond %{QUERY_STRING} ^ date=(.+?)
RewriteRule . - http://domain.com/404 [R=404,L]
The result was a 404 but not my own custom 404 page
How to redirect a url with a parameter to a custom 404 page?
If you have your own custom 404 that always should be displayed when the page can't be found, I would suggest changing that in your virtual host:
ErrorDocument 404 /pathtofile
Or via htaccess.
ErrorDocument 404 /pathtofile
If you would like to redirect based upon date parameter, this should do:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} date
RewriteRule ^(.*)$ 404.html [L]
</IfModule>
Hope this helps, if it does don't forget to check and up vote ;)
Synopsis:
localhost/root/admin is an existing folder
I want /root/admin to go to /root/index.php?url=admin without changing the url in the address bar.
The only except is if the requested file is an image
This is what I have written for the .htaccess file in localhost/root to try and do all this:
RewriteEngine On
RewriteBase /root/
RewriteCond %{REQUEST_URI} !index\.php$
RewriteCond %{REQUEST_URI} !(.*\.(png|jpg|gif))$ [NC]
RewriteRule (.*) index.php?url=$1 [QSA,L]
What this does instead is redirect localhost/root/admin to localhost/root/index.php and changes the url in the address bar to localhost/root/admin/?url=admin.
It will only not do this if I add a trailing slash (/) onto "admin".
I know that, on my mac laptop, this mod_rewrite code does exactly what it is meant to, but only when running it in the "Sites" folder and not in the localhost htdocs folder.
Any thoughts on what I can do to fix this?
I think you're just missing the "PT" flag to prevent an actual redirect. PT (Passthrough) means that Apache redirects the resource served internally, but the browser sees the same URL. (See the Apache wiki for more details: http://wiki.apache.org/httpd/RewriteFlags/PT)
RewriteEngine On
RewriteBase /root/
RewriteCond %{REQUEST_URI} !index\.php$
RewriteCond %{REQUEST_URI} !(.*\.(png|jpg|gif))$ [NC]
RewriteRule (.*) index.php?url=$1 [PT,QSA,L]
Note the only change was to add the flag. I tested this on my server and saw the behavior that I think you want.