easy question:
how to accept URL rewrite [A-Z]
index.php?id=forum
as
forum.htm
keep php
?
Can it be so simple?
RewriteRule ^/?([a-z]+)\.htm$ /index.php?id=$1
Related
I Want to rewrite the url using .htaccess
Plz Read the code, and you well Get to know What I mean
My URL :
article.php?id=1&title=example
Using this in .htaccess
RewriteRule ^article/([0-9]+)/([0-9a-zA-Z_-]+)$
article.php?id=$1&title=$2 [NC,L]
I get
article/1/example
What i need is
article/example
So something like this:
RewriteRule ^article/([0-9a-zA-Z_-]+)$ article.php?title=$1 [NC,L]
I'm trying to write this simple rewrite rule that is not working the way i'd like it to. I have this url: http://domain.com/fr/some_city/ that i'd like to rewrite to http://domain.com/fr/properties?city=1234
Here's my rewrite rule:
RewriteRule ^some_city$ proprietes?city=1234 [NC,L]
In the result page, there's nothing in $_GET['city']
Your regular expression only matches when the path is exact some_city, not fr/some_city.
You'll either have to add a RewriteBase before your rules, but that may cause issues if you have other rules in your htaccess.
RewriteBase /fr/
RewriteRule ^some_city$ proprietes?city=1234 [NC,L]
The other option is to rewrite the rule to be aware of the language:
RewriteRule ^/(.*)/some_city$ /$1/proprietes?city=1234 [NC,L]
Finally fixed ! If it can help anyone else:
As I was looking into PATH_INFO I noticed PHP was running as CGI, so added cgi.fix_pathinfo=0 to php.ini fixed it.
i want to redirect all of requests to a address that contains a regular expreession.
example
i.png to ../../templates/default-(something)/i.png
this is my Rewite Rule, but it not work.
RewriteRule ^(.*) ../../templates/default-(.*)/image/$1
thank you.
Again, not really sure what you're trying to do, but perhaps it's a folder?
If your structure was http://......./xxxx/something/i.png
RewriteRule ^.*?/(.*?)/(.*?\.png)$ ../../templates/default-$1/image/$2
Would get you http://..../templates/default-something/image/i.png\
OR if you just want to redirect it to something you define:
RewriteRule ^(.*)$ ../../templates/default-something/image/$1
hi i am trying to make clean and neat url using rewrite rule
I want to achive :
abc.com/t/param1/param2
Rewite rule that I wrote
RewriteRule ^t/(.+)/(.+)$ t/index.php?v=$1&t=$2 [L]
but it doen't work it redirects to :
http://abc.com/?v=param1&t=param2
Your regex should only match characters that aren't slashes. So your rule should look like
RewriteRule ^t/[^/]+/[^/]+$ t/index.php?v=$1&t=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/$ /?v=$1&t=$2 [L]
I've got a .htaccess file that has got a rewrite rule in it as follows which works fine:
RewriteRule ^solicitorsin([^/]+)/all/([0-9]+)$ /search/searchresults.php?county=$1&page=$2 [L]
What I'm looking to do is to keep using this for if the page variable is 2 or higher, but if it's 1 I want to 301 redirect to a separate url (the same site) say http://www.domain.com/solicitorsinCOUNTY/
The problem is that if I try doing this using a 301 redirect or a rewrite rule it still performs the above rewrite rule as well so I end up with http://www.domain.com/solicitorsinCOUNTY/?county=COUNTY&page=1
I haven't done much with .htaccess before so I'm not even sure if this is possible, can anyone help please? It would be much appreciated.
If you are using a rewrite rule, then put the rule for page=1 above the other rule and make sure you have the [L] flag.
Alternatively, you can use RewriteCond to prevent the rule from being run on specific URLS like this:
RewriteCond %{REQUEST_URI} !^solicitorsin([^/]+)/all/1$
RewriteRule ^solicitorsin([^/]+)/all/([0-9]+)$ /search/searchresults.php?county=$1&page=$2 [L]