I am trying to make a redirect with specific variables and format.
Here is the format of the url I want:
https://example.com/1234/http%3A%2F%2F5external-link.com
https://example.com/1234/http://external-link.com
I have my htaccess setup like this
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^([0-9]+)/(.*)$ index.php?id=$1&url=$2 [L,NE]
What am I missing?
Related
I have installed a Drupal site in www.example.com/beta
I am trying to do the following
Redirecting users to /beta when they hit www.example.com which I have achieved
RewriteBase /beta
Modify the URLs. For example www.example.com/beta/products should be modified to www.example.com/products. I just need to remove the /beta from the url.
You can do it by this code:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^beta/(.*)$ /$1 [L,NC,R]
Regards.
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]
I need to 301 redirect all ?print=yes URLs to the URLs without ?print=yes that contain the same name in them through .htaccess. Currently the button to PRINT is present in the header of the website so it's more than 70 URLs to fix... Removing the button to PRINT the page will ruin the design quite a bit, so it's not really an option.
I think it needs to be a RedirectMatch rule, but how do I write it?
Example: redirect 301 from domain.com/faq/?print=yes to domain.com/faq
Thanks in advance!
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 %{QUERY_STRING} ^print=yes$ [NC]
RewriteRule ^ %{REQUEST_URI}? [R=301,L,NE]
I am not sure if redirect can do the same but here is how I would do it with rewrite
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\?print=yes$ $1 [NC]
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]
I am trying to get /game/game-name/ to redirect to /game.php?g=game-name
The code I am using in my .htaccess is:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^game/([a-zA-Z0-9]+)/$ game.php?g=$1
But when I go to /game/game-name/ I get a 404 Error. Any help would be appreciated.
Thanks!
That's because your rule transform this url /game/game-name/ into this /game/game-name/game.php?g=game-name
What you need to do is either this :
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^game/([a-zA-Z0-9]+)/$ /game.php?g=$1
Or this :
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^game/([a-zA-Z0-9]+)/$ game.php?g=$1