I'm working on a PERL site which uses the medoc ecommerce system, and I've found that is spits out really ugly URL's which have no meaning to users or search engines:
https://www.example.com/cgi-bin/live/ecommerce.pl?site=test.com&dept_id=01&sub_dept_id=01&menu=currency&zone=test
I want to rewrite this so it's something simple like https://www.example.com/travel-money/home-delivery
Any ideas how I would go about this?
There are perhaps 50 different cgi-bin URL's each with multiple parameters, and I'd like to rewrite all of them individually.
I came up with two different rewrite rules, but neither worked. I couldn't find any examples with multiple parameters:
Option 1:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} ^site=test.com&dept_id=01&sub_dept_id=01&menu=currency&zone=test$
RewriteRule ^/cgi-bin/live/ecommerce.pl https://www.example.com/travel-money/home-delivery [L,R=301]
Option 2:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*)test.com&dept_id=01&sub_dept_id=01&menu=currency&zone=ice$
RewriteRule ^cgi-bin/live/ecommerce.pl$ travel-money/home-delivery? [R=301,L]
Thanks,
Related
I'm having a bit of a trouble finding the right way to this:
I'm about to launch a site, www.domain.com, but it's not quite yet ready for the public eyes just yet. So I want to redirect all visitors (except myself) to www.domain.com/teaser.html.
How can I do this, so I keep the site content hidden from visitors, without creating a loop if I redirect base url? How would a htaccess string look like?
If I create something like this:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^xxx.xxx.xxx.xxx
RewriteRule .* /coming-soon.html [R=302,L]
It just create a loop. How can I do this without creating a loop?
As mentioned in this question.
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !=123.45.67.89
RewriteRule index.php$ /teaser.php [R=301,L]
I have a very big forum (230k threads, 3 million posts) that has a large number of 404 pages reported on Google Webmaster Tools, to the tune of about 14,000 404 URLs. Google is probably showing these 404s because I have incoming links to them, meaning I'm losing a lot of SEO benefit by not having these links follow through to the actual page.
I know why I have this problem, a year ago the URLs on my site were changed back to vBulletin default so that they look like this:
http://www.domain.com/showthread.php?t=323653&p=4230256
I would like to keep them this way since they've been that way for a year. The problem is that there were two previous formats that are showing 404 errors:
These:
http://www.domain.com/forums/showthread.php?t=21461
http://www.domain.com/forums/showthread.php?t=16187
Which just need to have forums/ removed from the URL, and these:
http://www.domain.com/forums/f8/39840-infractions_system_how_works.html
http://www.domain.com/forums/f11/67410-viewing_ijji_gunz_replays_while_offline.html
Which are a funky URL structure that was created back when I had vbSEO installed.
/forums/ needs to be removed and I think that the numbers 39840 and 67410 are probably the thread id. I think there's everything we need in the URL to rewrite but I'm not entirely sure how to achieve it using htaccess.
Assuming, your .htaccess is located at website root "/"
RewriteEngine on
RewriteBase /
# removes "forums/"
RewriteCond %{REQUEST_URI} !^/showthread.php$ [NC]
RewriteRule ^forums/([^/]+)$ $1 [R=301,NC,L]
# parses thread id
RewriteCond %{REQUEST_URI} !^/showthread.php$ [NC]
RewriteRule ^forums/[^/]+/(\d+)-.*$ showthread.php?t=$1 [R=301,NC,L]
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 /
# to redirect /forums/f8/39840-something.html to
# /showthread.php?t=39840
RewriteRule ^forums/[^/]+/([^-]+)-[^.]+\.html$ /showthread.php?t=$1 [R=301,NC,L,QSA]
# to redirect /forums//showthread.php?t=39840 to
# /showthread.php?t=39840
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^forums/([^/]+)/?$ /$1 [R=301,NC,L]
I'm working on redirecting a bunch of URLs to a new schema, basically from:
http://www.gamikaze.tv/?XHh-1Z56av0
to:
http://www.gamikaze.tv/#!/videos:XHh-1Z56av0
I tried to find examples of that, but all queries examples I've seen are using a key/value pair, and this only contains one value. Also, the URL doesn't fundamentaly changed - both URLs are using index.php. How could that be achieved using an .htaccess?
Try this code.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^([a-z0-9-]+)$ [NC]
RewriteRule ^$ /#!/videos:%1? [L,R=301,NE]
Hi Stackoverflow community,
I've been reading through most of the other .htaccess questions, and tried different solutions on my .htaccess file but with no success.
Here's the thing: I have a website (based on CodeIgniter) that already has a good SEO positioning. Now, the customer wants it translated to another language, but I dont want to lose that SEO so I thought of redirecting a URL like http://www.domain.com/contactUs to http://www.domain.com/en/contactUs, being (en) the current positioned language. CI would handle the other language as usual without problem. Im currently doing tests on localhost, so the following rules will have only "domain" instead of "domain.com".
I've tried these Rewrite rules:
RewriteEngine on
Options +FollowSymlinks
RewriteCond ^(.*)/domain/(.*) !^/en/
RewriteRule ^(.*)/domain/(.*)$ $1/domain/en/$2
I want the RewriteCond to filter URLs coming in the new language so that the RewriteRule is not executed. What am I doing wrong?
Do this:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/en/ [NC]
RewriteRule ^(.*)$ /en/$1 [L]
You should put all your text in unique language files, then load them like so:
$this->config->set_item('language',"your_language");
$this->lang->load('default', "your_language");
To write out the content, the use:
$this->lang->line('message_id');
More info:
http://codeigniter.com/user_guide/libraries/language.html
This should more efficient than creating a duplicate site while still being SEO friendly. In fact, it should be more SEO friendly.
RewriteCond $2 !^en/
RewriteRule ^(.*)/domain/(.*)$ $1/domain/en/$2
How can I create a PHP page system that we access without .php extension and without ?page= variable?
There's a simple exemple:
http://www.exemple.com/portfolio/1
Instead of:
http://www.exemple.com/portfolio.php?id=1
It would be great for me because I'm a web designer and this is a thing I never did. So it would be good to know this! Also I will use this in my website.
you would need the following in your .htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*[^/])/?$
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule .+ %1.php [QSA,L]
You're looking for mod_rewrite.
RewriteEngine On
RewriteRule ^/profile$ /account.php?profile [L]
Create .htaccess file in your web root and enter following.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^account/([0-9]+)$ account.php?id=$1
OR
See mod_rewrite, in case URL rewriting, if you trying to do such.
You can use multiviews, or better and more used: mod_rewrite module from apache. It can be via a .htaccess file where you create rewrite rules like
RewriteEngine On
RewriteRule ^(.*)?(.*)$ /$1.php?Action=$2 [L]