I'm writing a website on custom MVC. I have URLs like this:
http://myweb.com/goods/?id=12&size2
Could you please help me out with rewrite rules to get a URL like this:
http://myweb.com/goods/id12/size2
You can use the Rule in /.htaccess :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ /goods/?id=$1&size=$2 [NC,L]
This will internally redirect
/2/12
to
/goods/?id=2&size=12
Related
Hi can any one help me write this htaccess code for the url mentioned below.
my url is soemthing like this http://localhost/worldofcontrol/search/ic3500a192c
and i want this to be changed to http://localhost/worldofcontrol/ic3500a192c
and my htaccess code is
RewriteEngine On # Turn on the rewriting engine
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)/?$ search/product_details.php?id=$1 [NC,L]
i have been trying to make my urls "pretty" / human readable, the urls at the moment are:
[BASE_URL]/?action=viewProposal&proposaltitle=tesst
I want to rewrite them to be just [BASE_URL]/tesst
I tried using the following code and modifying it but it wouldn't work, ie. it didn't redirect the pages but didn't throw any errors.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^users/(\d+)*$ ./profile.php?id=$1
RewriteRule ^threads/(\d+)*$ ./thread.php?id=$1
RewriteRule ^search/(.*)$ ./search.php?query=$1
Will the PHP GET functions still work properly as ?action defined whether its a view / edit / delete?
I am assuming base url your index.php try following rule,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)$ index.php?action=viewProposal&proposaltitle=$1 [QSA,L]
i've encountered the following problem:
The .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule view/^(.*)$ view.php?id=$1 [L,QSA]
Is not rewriting my urls
The friendly URL should be like this
https://domain.tld/view/1
And the original url should be rewritten like this:
https://domain.tld/view.php?id=1
The result of the htaccess above is a 404.
Try
RewriteRule ^view/(.*)$ view.php?id=$1 [L]
I am trying to perform a url rewrite where a url like "http://localhost/mywork/product/MTg=/productinfo/" should appear like "http://localhost/mywork/MTg="
Also, the "MTg=" is dynamic and will be varying.
I am not sure as to how to achieve it, can anyone please suggest what RewriteRule i should be writting in my .htaccess
Create mywork/.htaccess file it doesn't exist and have this rule:
RewriteEngine On
RewriteBase /mywork/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ $1/productinfo/ [L]
What URL rewrite rule should I put in .htaccess to re-write this:
http://www...com/one/john
into this:
http://www...com/one/two/index.php?profile=john
This ought to do it. Anything following /one that doesn't include a / will be passed into the profile parameter.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^one/([^/]+)$ /one/two/index.php?profile=$1 [L,QSA]