change url and access to file by htacess - .htaccess

My real url is:
/a/bc/de/test/1.jpg
I want access to my file by this url without redirect:
/abcde/test/1.jpg
How can i do that?

This is pretty strange rewrite rule but you can try this rule in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^([a-z])([a-z]{2})([a-z]{2})/(test/.+)$ /$1/$2/$3/$4 [L,NC]

Tanx for help, this is correct:
RewriteRule ^([0-9a-f]{1})([0-9a-f]{2})([0-9a-f]{2})/([0-9a-z-]{1,})/(.+)$ /$1/$2/$3/$4/$5 [L,NC]

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

Redirect to a specific page with parameter using the htaccess rule

I have a url like:
v1/club/club-name/12 and v1/club/club-name/13
I want it to redirect to:
v1/features.php?id=12and v1/features.php?id=13
Can anyone please tell me how can I do that with .htaccess?
Thanks.
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^v1/club/[^/]+/(\d+)/?$ v1/features.php?id=$1 [L,NC,QSA]

.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 with GET param

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]

.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