I have a search form and when I make a search I get this URL "http://****/video/view/search/?imeto_tam=tarsene" but I want to replace this the "?imeto_tam=tarsene" with the word I search for and my address to look like this - "http://****/video/view/search/tarsene". Generally I use mod_rewrite on my site and it's working for my links but it's not working for the form-s. Could someone tell me how to do it?
RewriteEngine On
RewriteRule ^view/([0-9a-zA-Z\-\(\)]+)/?$ index.php?a=$1 [L]
RewriteRule ^view/([0-9a-zA-Z\-():]+)/([0-9a-zA-Z\-():\.,]+)$ index.php?a=$1&id=$2 [L]
These rules would go into your root .htaccess file and 301 redirect the querystring imeto_tam to the folder and then the next rule would make it get passed to your code (index.php)
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?imeto_tam=([^&]+)(&.*)?$ [NC]
RewriteRule ^video/view/search/(index\.php)?$ /video/view/search/%2/? [R=301,L]
RewriteRule ^video/view/search/([^/]+)/$ /video/view/search/index\.php?imeto_tam=$1 [L]
Related
I am looking for a way to create a short URL path for a longer URL on my page
the long url is: domain.com/tagcloud/user.html?t=1234ABCD
i would like to offer a short version of the URL to easy access it:
domain.com/t/1234ABCD
I tried a few examples but I just don't get it how I could forward these rules.
RewriteRule ^(.*)/t/$ /tagcloud/user.html?t=$1 [L]
I am also using MODX so they already use rules.
in addition my htaccess file
RewriteEngine On
RewriteBase /
# Always use www
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
I must keep the code snippets above in my htaccess file. The first one simply forwards http://domain.com requests to www.domain.com
The friendly URLs part is needed to translate the internal IDs of my CMS with the alias of the URL. This feature must remain because the entire site cannot be influencted by the changes I try to make in htaccess...
I simply would like to add a listener that only if the URL matches www.domain.com/t/abcd1234
Therefore I need something that identifies the www.domain.com/t/ URL
your help is much appreciated
Try this:
RewriteCond %{REQUEST_URI} ^/t/.*
RewriteRule ^t/(.*)$ /tagcloud/user.html?t=$1 [R=301,L]
what i am trying to do is this:
If url http://example.com/foo/foo.php is called it should be redirected with 301 to http://example.com/bar/foo.php
AND
if url http://example.com/bar/foo.php is called it internally calles the /bar/foo.php script but browser url is not changed (remap).
my rules look like this
RewriteRule ^foo/foo.php(.*) bar/foo.php$1 [R=301]
RewriteRule ^bar/foo.php(.*)$ foo/foo.php$1 [PT]
But this gives me too many redirects error.
Each rule activated separately works but together they seem to conflict...
You can either match against the actual request:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /foo/foo.php
RewriteRule ^foo/foo.php(.*) bar/foo.php$1 [R=301]
RewriteRule ^bar/foo.php(.*)$ foo/foo.php$1 [L]
Or prevent rewrite looping altogether:
RewriteCond %{ENV:REDIRECT_STATUS} !200
RewriteRule ^foo/foo.php(.*) bar/foo.php$1 [R=301]
RewriteRule ^bar/foo.php(.*)$ foo/foo.php$1 [L]
I have a URL like
www.testwebsite.com?param1=abc
or
www.testwebsite.com/?param1=abc
I need to redirect to
www.testwebsite.com/level1/xyz.html?customparam=123¶m1=abc
I tried working on rewrite url but i am still new to this and need some help to achieve the solution
This is what i did till now
RewriteCond %{QUERY_STRING} param1=(.+)
RewriteRule ^/$ /level1/xyz.html?customparam=123¶m1=%1 [R=301,L]
Try adding the following to the .htaccess file in the root directory of your site.
Only param1 will be captured and passed through, other query string params will be dropped.
RewriteEngine on
RewriteBase /
#if the param1 parameter is present
RewriteCond %{QUERY_STRING} (^|&)(param1=([^&]+))(&|$) [NC]
#redirect
RewriteRule ^$ level1/xyz.html?customparam=123&%2 [L,R=301]
I'm at a total loss trying to integrate a mod_rewrite in my existing page. Currently, I am building a new site from scratch, and there i have some nice clean url's such as:
http://www.example.nl/nl/example
The old site, running Cms made simple, has some not-rewritten url's that would need to be redirected to the new pages. Those url's look like this:
http://www.example.nl/index.php?page=cake-and-pie&hl=nl_NL
But shorter versions of that like:
http://www.example.nl/index.php?page=cake-and-pie
also work.
It took me a while to figure out that url's with parameters cannot simply be redirected with "Redirect 301", like i'd normaly do. So i tried some online mod_rewrite generators like this and this, but the rules outputted by those result only in 404 errors, (the redirect doesn't work at all).
My .htaccess file current looks like this:
RewriteEngine On
RewriteBase /
# remove .php;
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
RewriteRule (.*)/index$ $1/ [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
The old pages would seize to exist.
How do i redirect the old pages to the new ones?
Thanks.
EDIT
RewriteCond %{QUERY_STRING} =page=pie
RewriteRule ^index\.php$ /nl/? [L,R=301]
RewriteCond %{QUERY_STRING} =page=pie&hl=nl_NL
RewriteRule ^index\.php$ /nl/? [L,R=301]
Seems to do the trick. This is of course manual for every url, but i only have a few.
RewriteEngine On
RewriteBase /
RewriteRule ^(.+)/([^/]+)/?$ index.php?page=$1&hl=$2
RewriteRule ^([^/]+)/?$ index.php?page=$1 [QSA]
RewriteEngine On
RewriteRule ^/ai?$ /Market/publish.jsp [QSA,L,PT]
RewriteRule ^/ar?$ /Market/MailDispatch [QSA,L,PT]
RewriteCond %{HTTP_HOST} !^web\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://web.example.com/$1 [L,R]
#How skip www\. to web\. for this 1 ?
#RewriteRule ^/vi/?([0-9]+)\.htm$ /Market/vi.do?id=$1 [PT,L]
RewriteRule ^/li /Market/list.do [QSA,PT,L]
RewriteRule ^/vi/locations.jsp /Market/locations.jsp [PT,L]
ErrorDocument 404 /notfound.html
Nearly undoable(?) I try http://example.com/vi/{N}.htm should redirect to http://web.example.com/vi/{N}.htm where N is dynamic ID.
Seen mod_rewrite with subdomain and url pattern
There is no clear way to make eg http://example.com/vi/1096.htm pass up to next version http://web.example.com/vi/1096.htm where number is dynamic. I tried
A rule with the following scheme should do it:
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^/vi/\d+\.htm$ http://web.example.com%{REQUEST_URI} [L,R=301]
It’s important to put this rule in front of those rules that do an internal redirect. Otherwise an already internally rewritten URL could be rewritten externally.
If you want to use this rule in a .htaccess file, remove the leading slash from the pattern in RewriteRule.