I want to rewrite the address:
www.mysite.it/en/material-65 to
www.mysite.it/material/materialDetail.php?id=65&lang=en
I put this:
RewriteRule ^/(.+?)/material-([0-9]+)$ /material/materialDetail.php?id=$2&lang=$1`
on the .htaccess file but it doesn't work.
Related
I want to redirect all urls which includes /en with /de
for example redirect http://www.example.com/en/about/ to http://www.example.com/de/about/
You can try below rule in your .htaccess file:
RewriteRule ^en/(.*)$ /de/$1 [R=301,L]
Read the mod_rewrite manual for redirecting and rewriting URLs.
Reference : https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html
I have updated my website and now i have a new URL structure. My old structure was like: subdomain.domain.com. My new structure is like: www.domain.com/folder/subdomain
I already added a subdomain wildcard to my dns (*.domain.com) and was hoping for a htaccess rule to redirect my old urls to my new urls.
(how) can this be done?
Thanks.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^((?!www\.)[^.]+).domain\.com$
RewriteRule ^ /folder/%1%{REQUEST_URI} [L]
Try putting this code in the htaccess file.
I have some files with .exe extension in subfolder /files/
I would like to redirect all queries
/files/somename.exe
to
/script.php?name=somename
Also I have a root .htaccess and local .htaccess in /files/ folder.
I think I should change local .htaccess, but it doesn't work.
what i tried -
RedirectMatch ./([_A-Za-z0-9-]+).exe$ /script.php?name=$1
Please help!
You can use this rule:
RedirectMatch 302 ^/files/([_A-Za-z0-9-]+)\.exe$ /script.php?name=$1
OR if you want internal rewrite only then put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^files/([\w-]+)\.exe$ script.php?name=$1 [L,NC,QSA]
I have very specific question, I want to solve it using .htaccess and mod_rewrite, I want to make rule in .htaccess file using mod_rewrite, so when somebody visit my site ex.
mysite.com , mysite.com/css/style.css file should be read from other location mysite.com/version1/css/style.css, if I say it otherwise, style.css should not be "picked up" from root folder, but sub-folder.
Try adding this to the htaccess file in your document root:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$ [NC]
RewriteRule ^css/(.*)\.css$ /version1/css/$1.css [L]
I am moving a Magento site from example.com/shopping to example.com and I have to 301 redirect all of the URLs to the new location (example.com). I am assuming I can use mod_rewrite in the .htaccess file to create a rewrite rule to do this? I tried to learn how to use mod_rewrite, but the syntax is so complex for me.
There are hundreds of pages that need to be redirected. Example:
http://www.example.com/shopping/product-category-1/product-sub-category.html
TO
http://www.example.com/product-category-1/product-sub-category.html
This is so that people don't end up with a 404 error when they enter the site via an old URL.
Try adding this to the htaccess file in your document root, preferably above any rules you may already have there:
RewriteEngine On
RewriteRule ^shopping/(.*)$ /$1 [L]
If you want to redirect the browser so that the new URL appears in the location bar, add an R flag in square brackets:
RewriteEngine On
RewriteRule ^shopping/(.*)$ /$1 [L,R=301]