My url is http://example.com/index.php?pid=software_details&p=18 I want to change my url to http://example.com/software_details/18. I used .htaccess file to do this but it's not working... please someone help me! thanks in advance...!
My .htaccess code is as bellow:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/([^/]*)/([^/]*) /index.php?pid=$1&p=$2 [L]
</IfModule>
I think the rule below should achieve what you are looking for:
RewriteRule ^/(.*)/(.*)$ /index.php?pid=$1&p=$2 [R=301,L]
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 am using given below code to redirect to login page,When enter url in address bar e.g.(exmple.com/web/) then redirect to "http://exmple.com/web/login.php" How ?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^exmple.com/web/$
RewriteRule ^$ http://exmple.com/web/login.php [L,R=301]
Try this
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.exmple\.com$
RewriteRule ^$ http://www.exmple.com/web/login.php[L,R=301]
%{HTTP_HOST} variable represents the current domain name without the path segment . Your RewriteCond is invalid because it is trying to match example.com/web/ as domain name which is a non existent domain and the RewriteCond fails.
Change the following condition :
RewriteCond %{HTTP_HOST} ^exmple.com/web$
to
RewriteCond %{HTTP_HOST} ^(www\.)?exmple.com$
You can use the following :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?exmple.com$
RewriteRule ^(web/?)?$ http://exmple.com/web/login.php [L,R=301]
You can also use RedirectMatch in your htaccess to redirect an url to a diffrent location :
RedirectMatch ^/web/?$ http://exmple.com/web/login.php
Clear your browser's cache before testing these solutions.
I have Google'ed long for this but can't find an answer.
I have this URL:
www.mysite.com/index.php?tip=1
(respectively www.mysite.com/?tip=1)
And want it to rewrite to:
www.mysite.com/tip/1
Your help would be appreciated.
You will need to enable rewrite module in your apache config and put the following settings on the .htaccess file your base folder
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^tip/(.*) /index.php?tip=$1 [L,NC,QSA]
at this site:
http://www.syriadailynews.com/sdn/
I used codeigniter with segment based url
and it works fine at localhost (xampp)
but after uploded the site, all urls not working
this is my .htaccess
Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
AddDefaultCharset UTF-8
I edit config.php to this:
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'AUTO';
It's worked now ! ^_^
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]