I need to get var1 and var2 from the URL bellow using .htaccess URL rewrite.
URL:
link
HTACCESS:
RewriteEngine On
RewriteRule ^tmp/([^\.]+)(here i need help)\.(png|jpg|gif)$ image.php?image=$1.$4&size=$2&position=$3 [NC,L]
RESULT SHOULD BE:
image.php?image=image-file-name.jpg&size=var1&position=var2
You can use this code:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^tmp/(.+)-([^-]+)-([^.]+)\.(png|jpe?g|gif)$ index.php?image=$1.$4&size=$2&position=$3 [L,QSA,NC]
Related
I'm currently using a CMS that rewrites all URLs and currently I have a URL like this:
http://www.domain.com/folder/?user=user1
I'm looking to have that rewrite to: index.php?r=search&term=$1
Would something like this work?
RewriteRule ^/?user=(.*) index.php?r=search&term=$1 [L]
Seems to be giving me trouble. Any suggestions?
The query string is not part of the URI-path test it in the rule. It is at QUERY_STRING variable.
You may try this:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} user=([^/]+)/? [NC]
RewriteRule ^folder/? /index.php?r=search&term=%1 [L,NC]
try ( not tested)
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^folder1/?user=(.*)$ index.php?r=search&term=$1 [R=301,L]
I have a file path that looks like this: /cgi-bin/folder/script.cgi?t=1&u=http://domain.com/url/url-2/
What I want to do is create a rewrite rule to pull the querystring u= and then redirect to that URL, I've been working for a while on this with no success.
RewriteRule ^cgi-bin/folder/script.cgi?t=1&u=(.*)$ $1 [R=301,L]
Above is an example of one of my "solutions" that obviously didn't work. Any help is much appreciated. Thanks!
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+cgi-bin/folder/script\.cgi\?t=1&u=([^\s&]+) [NC]
RewriteRule ^ /%1 [R=302,L,NE]
I want this URL:
http://www.mydomainblabla.com/s/can+you+drill+shrinky+dinks?.html
to be rewritten to this one:
http://www.mydomainblabla.com/search.php?q=can+you+drill+shrinky+dinks?
I am using this mod_rewrite rule in my .htaccess to accomplish this
RewriteRule ^s/(.+).html$ search.php?q=$1 [L,QSA]
However, the result is not as I want it, when I go to the first url, I get a page not found message.
The same problem occurs when I visit this url:
http://www.mydomainblabla.com/s/http://www.zakgeldnodig.nl/.html
which should be rewritten into this one:
http://www.mydomainblabla.com/search.php?q=http://www.zakgeldnodig.nl/
What modifications should I make to my .htaccess to make this work?
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+s/(.+?)\.html [NC]
RewriteRule ^ search.php?q=%1 [L,NE]
How to write the htaccess rule based on
http://mysite.com/http://google.com -> http://google.com
http://mysite.com/http://facebook.com -> http://facebook.com
should redirect with 302 to that url ( except the main file index.php ), so the actual referrer would be hidden,
Thank you.
Put this code in your .htaccess under DOCUMENT_ROOT:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(https?://[^\s]+) [NC]
RewriteRule ^ %1 [R,L]
If I make the assumption that all your links will start with a protocol then the following will work:-
RewriteEngine On
RewriteBase /
RewriteRule ^(https?)://(.*)$ $1://$2 [NC,L,R=302]
I have a page name page.php and my url as localhost/mysite/page.php , now how can i change the url using .htaccess file to localhost/mysite/somethinghere1/somethinghere2/page.php
It tried using the below code but it doesn't work out.
<IfModule mod_rewrite.c>
# Enable Rewriting
RewriteEngine On
# Rewrite user URLs
# Input: user/NAME/
# Output: user.php?id=NAME
RewriteRule ^somethinghere1/somethinghere2/.php? page.php
</IfModule>
how can i acheive this.
What about this:
RewriteRule ^somethinghere1/somethinghere2/([^/\.]+).php/?$ page.php
Use it like this:
RewriteRule ^(mysite/)somethinghere1/somethinghere2/(.*\.php)/?$ $1$2 [L,NC]
Also make sure this in .htaccess file in your DOCUMENT_ROOT directory.
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/page.php /page.php?first=$1&second=$2 [NC]
This is the basic code , you can play with it to fit your needs like the following edit :
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/([^/]+) /$3.php?first=$1&second=$2 [NC]
So x/y/z would be z.php?first=x&second=y