Hi i make one cms sites and i need to rewrite my url
current my url is http://www.example.com/index.php?link=pages&cmsid=2&cmsLink=Carpet
it refers the cmsLink
I want my url like http://www.example.com/Carpet
I am using the following code
Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteBase /
RewriteRule ^index.php?link=(.*)&cmsid=(.*)&cmsLink=(.*) $3
To achive this url it not directly possible with .htaccess
I use regular expression and other tings in htacess as well
I put remove the cmsid
current my url is http://www.example.com/index.php?link=pages&cmsLink=Carpet
RewriteCond %{REQUEST_URI} !/admin
RewriteCond %{REQUEST_URI} !^/(.*).php
RewriteBase /
RewriteRule ^([^/]+)/?$ index.php?link=pages&cmsLink=$1&%{QUERY_STRING} [L]
it return me http://www.example.com/Carpet
Try changing your last rule to this:
RewriteRule ^(.+)$ /index.php?link=pages&cmsid=2&cmsLink=$1
Since you want to have url like http://www.example.com/Carpet, so cmsid and link in your url has to be hardcoded to 2 and pages.
Related
I want to redirect image request if current url contain specific string, for example /id/
so far i tried the following syntax on htaccess.
RewriteCond %{REQUEST_URI} /id
RewriteRule (.*)/image1.png$ $1/image1-id.png
i am not good with htaccess, please point me.
Try this
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/id/(.*)$
rewriterule ^image1.png(.*)$ image1-id.png$1 [r=301,nc]
I am currently working on a signup page and I was wondering if I could modify the URL without the .php extension.
For example, it is now
www.xyz.com/signup.php
And what I would like achieve is
www.xyz.com/signup
Now I am assuming that I might have to use the htaccess file, but I am not sure about it.
First rule will redirect from signup.php to domain.com/signup/.
Second rule will redirect internally so the URL will remain domain.com/signup/ while displaying the content of domain.com/signup.php.
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Redirect /signup.php to /signup/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+signup\.php\s [NC]
RewriteRule ^ /signup/? [R=302,L]
# Internally forward /signup/ to /signup.php
RewriteRule ^signup/?$ /signup.php [NC,L]
What you're looking for is called URL rewrite. Take a look at this tutorial for beginners: http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/.
You can duplicate with .htaccess
RewriteEngine On
RewriteRule singup$ singup.php [NC,L]
I want to change alle dynamic url's to static ones,
but after rewriting the dynamic url's are still responding/available.
What did I do =>
I found this Tool for SEO:
http://www.webconfs.com/url-rewriting-tool.php
I entered this:
.../filmdetails.html?var=ich_einfach_unverbesserlich_ii
Then I put into my .htaccess this:
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^filmdetails/(.*)/$ filmdetails.html?var=$1
Works, but now I got a problem: This URL is still available and should not be: .../filmdetails.html?var=ich_einfach_unverbesserlich_ii
How do I get rid of the dynamic url's?
Your rule only rewrites the nicer looking URL to the one with a query string. Rules only work from a "pattern" -> "target" way, the mapping won't magically work the other way. You'll have to create a separate rule in order to redirect the browser:
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /filmdetails\.html\?var=([^&\ ]+)&?([^\ ]*)
RewriteRule ^ /filmdetails/%2/?%3 [L,R=301]
Try:
Options +FollowSymLinks
RewriteEngine On
#set this to path to your filmdetails.html file (from the document root)
RewriteBase /
#checking if redirect already happened
RewriteCond %{ENV:REDIRECT_PASSED} !^$
RewriteRule $ - [L]
#Your rewrite rule
RewriteRule ^filmdetails/(.*)/$ filmdetails.html?var=$1 [L,E=PASSED:1]
#redirecting from filmdetails.html with query string ?var=something
RewriteCond %{QUERY_STRING} ^var=(.+)$ [NC]
RewriteRule ^filmdetails.html$ filmdetails/%1/? [R]
filmdetails.html?var=something will be redirected to filmdetails/something
Can anyone help with .htaccess URL rewriting rule.
I need to redirect pages like this:
www.website.com/index.php?a=some-word-some-other-word
www.website.com/index.php?a=something
www.website.com/index.php?a=some-other-thing
All that pages have the same content as www.website.com/index.php
to
www.website.com/index.php or www.website.com/
I already asked for this and I got this:
RewriteEngine On
RewriteBase /
#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule .* http://www.website.com/? [R=301,L]
It does that, it redirect those pages to home page (root of site). But I have some pages with URLs like:
i.php?a=something-something-something
and problem is that .htaccess code above affect those links too.
Can anyone make that code just to redirect links for pages based on index.php?a= and not for i.php?a= too.
Try this and tell me if it works:
RewriteEngine On
RewriteBase /
#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule ^index\.php$ http://www.website.com/? [R=301,L]
I have a website and i am using .htaccess to generate SEO friendly url. I want if someone type: mysitename.com/anypagename he should be redirected to mysitename.com/anypagename/
The basic is i want to concat a "/" at the end. Can anyone tell me the how to write this in my .htaccess file
Try following rule in your .htaccess file:
RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ /$1/ [L,R=301,NE,QSA]
R=301 will redirect with https status 301
L will make last rule
NE is for no escaping query string
QSA will append your existing query parameters
$1 is your REQUEST_URI
PS: If you want to avoid appending a / after a regular file then add this condition as well above:
RewriteCond %{REQUEST_FILENAME} !-f