I have a product page and need the user to access it , but with the product name.
How it works: localhost/product?id=2
I want it that way: localhost/computer
My code .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^confirmation/?$ confirmation.php [NC,L]
RewriteRule ^/product/([^/]+)/$ product.php?id=$1 [QSA,L]
</IfModule>
Is not working, where I'm going wrong ?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^confirmation/?$ confirmation.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?([^/]+)/?$ product.php?id=$1 [QSA,NC,L]
</IfModule>
Related
How to redirect from:
https://example.com/blog/?p=title-of-blog-post
to:
https://example.com/blog/title-of-blog-post
In the /blog/ folder, I have the following .htaccess file:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./index.php
</IfModule>
I have tried into the .htaccess of the root, the following code, but it returs 404 Not found:
.htaccess in /public_html/
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} \s/blog/\?p=([0-9]*)\s [NC]
RewriteRule . blog/%1? [R=301,L]
RewriteRule ^blog/([0-9]+)$ blog/?p=$1 [L]
You must use new rule in blog/.htaccess only. Here is suggested code:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{THE_REQUEST} \s/blog/\?p=([\w-]+)\s [NC]
RewriteRule ^ %1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([\w-]+)/?$ ?p=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have the following .htaccess file, when I type http://adidas.localhost/ in the URL the 'store' query variable does not get appended, however when I add a single character for example http://adidas.localhost/1 it will work perfectly fine, but not without any characters after the slash, I've tried everything and haven't been able to come up with a solution, thanks.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^([^\.]+)\.localhost$ [NC]
RewriteRule ^(.*)$ http://localhost/?store=%1&uri=%{REQUEST_URI} [QSA,L]
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Try with:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^([^\.]+)\.localhost$ [NC]
RewriteRule ^(.*)$ http://localhost/?store=%1&uri=%{REQUEST_URI} [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
I've been looking few different tutorials about it like
https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
and I thought it would be easy to do my own rewrite rule but I don't know why it's not working.
this is what I have in my htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp2/
RewriteRule ^lol portafolio [NC,L] # Change feed URL
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp2/index.php [L]
</IfModule>
# END WordPress
and when I write wwww.domain.com/wp2/lol it's not redirecting me to wwww.domain.com/wp2/portafolio which this code:
RewriteRule ^lol portafolio [NC,L] # Change feed URL
should do.. I guess it's not correct. Why it's not doing the rewriting correctly? I need to rewrite a bunch of URLS.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Try this code. it will help you
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
I am trying to force SSL on HTACCESS file and all my efforts result in a loop on index.php.
This is my htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
My site works fine with this but no SSL.
I tried the following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ https://www.fakedomainlollol.com/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
The updated rewrite rule sends the site in a loop.
What is the error? What am I doing wrong here?
My .htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
#non www redirection
RewriteEngine On
RewriteCond %{HTTP_HOST} !^ruggedtrailsnepal\.com
RewriteRule (.*) http://ruggedtrailsnepal.com/$1 [R=301,L]
i am not getting / (slash) on some url , but some url's are working , how to solve this problem
link with problem
ruggedtrailsnepal.comtravel-info/visa-information.html
link without problem
ruggedtrailsnepal.com/company-info/about-us.html
Reorder your rules and use REQUEST_URI variable:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
#non www redirection
RewriteCond %{HTTP_HOST} !^ruggedtrailsnepal\.com$ [NC]
RewriteRule ^ http://ruggedtrailsnepal.com%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Better test this in a new browser to avoid old caches.