I need to be able to rewrite http://example.com/staging/details/?postid=23 so that it becomes http://example.com/staging/grandhotelterduin
I am not sure how the .htaccess rule should be?
I have came up with something like this
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^grandhotelterduin/(.*)$ ./details/?postid=23 [L,NC]
I am not sure I am doing this correctly, can you plz help
I want it such that the http://example.com/staging/grandhotelterduin/ get redirected to http://example.com/staging/details/?postid=23 but the url that appears in the browser is `http://example.com/staging/grandhotelterduin
Use this:
RewriteEngine On
RewriteRule ^grandhotelterduin$ /staging/details/?postid=23 [L]
It will give you the following URL:
http://sheetz.nl/grandhotelterduin
EDIT:
RewriteCond %{THE_REQUEST} /staging/details/?postid=([0-9]+) [NC]
RewriteRule ^ /staging/grandhotelterduin [L,R]
Related
I am trying to make a link that looks like https://www.exapmle.com/profile.php?u=8 to look like https://www.exapmle.com/profile/8
I have a tried variations of this in htaccess:
RewriteRule ^/profile/([0-9]+)/?$ profile.php?u=$1
RewriteRule ^/profile/([0-9]+)\.html /profile.php?u=$1
I don't know what i am doing wrong, the links don't change and I'm not getting any errors either
You may use this code in your site root .htaccess:
Options -MultiViews
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /profile\.php\?id=([^\s&]+) [NC]
RewriteRule ^ /profile/%1? [R=301,L]
# internal forward from pretty URL to actual one
RewriteRule ^/?profile/(\d+)(?:\.html)?/?$ profile.php?u=$1 [L,QSA,NC]
Please help me with a redirect issue.
I am trying to redirect from http://www.project/index.php/blog to http://www.project/blog.
I tried the following but it did not work
RewriteRule ^(blog)$ ./index.php/ [L]
Give this a try:
Options +FollowSymlinks
RewriteEngine on
Rewriterule ^index.php/blog(.*)$ http://www.project/blog$1 [r=301,nc]
If you want to append the requested path info at index.php, you might use this RewriteRule
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteRule ^ /index.php%{REQUEST_URI} [L]
I've never needed to use a .htaccess before and I'm fairly new to coding I'm trying to get localhost/index.php?id=123456789 to be passed as localhost/123456789/ but I just cant get the HTaccess right, i've tried everything I could find from prevoius posts here, haha!
My current HTACCESS looks like this, however it doesnt do what I want.
RewriteEngine On
RewriteRule ^id/(\d+)$ /index.php?id=$1 [NC,QSA,L]
You can do it with mod_rewrite in .htaccess however I'm not sure from your question which direction you want it to be passed to.
If you want people to type the php script in the URL bar you want:
RewriteEngine on
RewriteCond %{QUERY_STRING} id=([0-9]+)
RewriteRule ^index.php$ %1/
Or if you want people to enter the "pretty" version but for your server to load the PHP script you need:
RewriteEngine on
RewriteRule ^([0-9]+)/$ index.php?id=$1&%{QUERY_STRING}
For both ways and 301 redirect to pretty URL:
RewriteEngine on
RewriteRule ^([0-9]+)/$ index.php?id=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} id=([0-9]+)
RewriteRule ^index.php$ %1/ [L,R=301]
I've having a bit of trouble figuring out how to mass redirect a lot of files.
http://www.mysite.com/verify.php?site=mydomain.com
to
http://www.mysite.com/verify/mysite.com
And of course "mysite.com" will always be a different domain so that should be dynamic.
This is the code that I was using:
RedirectMatch 301 ^/verify\.php\?site=([a-zA-Z0-9\.\-]+)$ /verify/$1
Can someone please post what I need to change to make this work or a correct version of my code above? Thanks for your time!
Try this:
EDIT:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^verify/(.*)$ verify.php?site=$1 [L]
Then try to load this in browser:
http://www.mysite.com/verify/mysite.com
Try one of the following:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /verify\.php\?site=([^&\ ]+)
RewriteRule ^ /verify/%1 [L,R=301]
Or
RewriteEngine On
RewriteCond %{QUERY_STRING} ^site=([^&]+)
RewriteRule ^/?verify\.php$ /verify/%1 [L,R=301]
First off I'm not an expert in htaccess stuff, but i try to accomplish the following for some SEO fixes.
When the url is loaded, without any params/rewrite it should get some data attached before it continues.
For example:
http://www.domain.com >>> http://www.domain.com/en/
I thought the rewrite was right like this, but didn't work (500)
RewriteCond %{REQUEST_URI} !^(en|nl|de|etc)$
RewriteRule ^(.*)$ /en/ [L,R=301]
added
RewriteRule ^(/?[^/]+) /index.php?rewrite=1 [L] # tell php we got a rewrite
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ $1/en/ [NC]