.htaccess rewrite with GET param - .htaccess

Im trying to transfrom link like this:
http://localhost/photohosting/user/view.php?img=60
Into something like that in users browser:
http://localhost/photohosting/60
Here my code for .htacces
RewriteEngine on
RewriteRule ^view.php(.*)$ /photohosting/user/view.php?img=$1 [L,QSA]
I'm not familiar with .htaccess so I can't found the mistake. Why this code doesn't work?
UPDATE: I've updated my .htaccess to:
RewriteRule ^([a-zA-Z0-9_-]+)$ user/view.php?img=$1 and now link like http://localhost/photohosting/60 works, but it misses param.

Try with the following rule:
RewriteRule photohosting/([0-9]+)$ /photohosting/user/view.php?img=$1 [L,QSA]

Related

What is wrong htaccess

I have the following htaccess rules but I dont know how to make it work:
RewriteEngine on
RewriteRule ^game/([^/]*)$ index.php?cash=$1
The following is the screen shot of my folders structure:
Can someone tell me how to get it to work? I have also tried:
RewriteRule ^index.php([^/]*)$ index.php?cash=$1
The URL that I want to display is: http://localhost/biteep/game/100 while the URL that I want the browser to go to is http://localhost/biteep/game?cash=100
Try to put a rewrite base into your .htaccess:
RewriteBase /biteep/
And this route should be enough:
RewriteRule ^game\/(\d+)$ index.php?cash=$1
So it works when I do this
RewriteEngine on
RewriteRule ^([0-9]+)$ index.php?cash=$1

.htaccess change the URL page with three conditions

I want to change the url of my page like
http://localhost/Dynobase/my_computer.php?name=Deny-computer&type=computer&select=1
to
http://localhost/Dynobase/Deny-computer/computer/data/1
and to my htaccess file code like this
RewriteRule ^([a-zA-Z_-]+)/([a-zA-Z_-]+)/data/([[0-9]]+)$ /my_computer.php?name=$1&type=$2&select=$3 [L,NC]
but that I could actually error 404
maybe there is something wrong in my code.
please help me.
Thank you
Try this in /Dynobase/.htaccess:
RewriteEngine On
RewriteBase /Dynobase/
RewriteRule ^([\w-]+)/([\w-]+)/data/([0-9]+)/?$ my_computer.php?name=$1&type=$2&select=$3 [L,NC,QSA]

.htaccess Rewrite /... to /?url=

I am trying to rewrite URLs like this: http://url.maxk.me/abc to http://url.maxk.me/?url=abc, but for some reason it is not working.
Please can you tell me what I am doing wrong?
RewriteEngine on
RewriteRule ^(?:.*)url.maxk\.me/(.*)/?$ url.maxk.me?url=$1
You shouldn't include the domain in the RewriteRule target resource.
It should look like the following if you want the "?url" part to be visible to the user:
RewriteRule ^(.*)$ http://url.maxk.me/?url=$1
Otherwise, if you don't want the user to see "?url", it should look like this:
RewriteRule ^(.*)$ ?url=$1
try using this:
RewriteRule ^(.*)$ ?url=$1

htaccess : rewrite urls

please help to rewrite Urls from
http://www.site.com/index.php?cat=catname
and
http://www.site.com/index.php?id=productname
to be like this
http://www.site.com/catname
and
http://www.site.com/productname
i think it will require php check if the page is cat work with it as cat
or its product work with it as product
in .htaccess file:
RewriteEngine On
RewriteRule ^([0-9a-z\-\_]+)?$ /index.php?id=$1 [L,QSA,NC]
category/product check must be done in index.php...
Or you can add extra slug
RewriteRule ^(category)/([0-9a-z\-\_]+)?$ /index.php?category=$1 [L,QSA,NC]
RewriteRule ^(product)/([0-9a-z\-\_]+)?$ /index.php?product=$1 [L,QSA,NC]
but url will look like http://site.com/category/catname
http://www.site.com/catname and http://www.site.com/productname
The problem with that scheme is that you can't tell whether it's a catalog name or a product name by the URL. As a result, you'll probably want something like this:
http://www.site.com/Catalog/catname and http://www.site.com/Product/productname
Which can then be implemented in a .htaccess file with the following rules:
RewriteEngine On
RewriteRule ^Catalog/(.+)$ /index.php?cat=$1 [L]
RewriteRule ^Product/(.+)$ /index.php?id=$1 [L]

.htaccess: Rewrite Problem

I'm creating a website. I have this code in the .htaccess file:
RewriteEngine On
RewriteRule ^/([-a-zA-Z0-9_]+)/$ /redirect.php?id=$1
But when I go to, for example /ASEi it says 404 Not Found. What's the problem?
Try this instead:
RewriteRule ^/([-a-zA-Z0-9_]+)/$ /redirect.php?id=$1
I found it, the problem was the first /. The .htaccess now looks like: RewriteEngine On
RewriteRule ^([-a-zA-Z0-9_]+)$ redirect.php?id=$1

Resources