I am using OSCLASS script and I am using .htaccess to rewrite the urls. The default .htaccess that OSCLASS makes, gives urls like this ( http://myhost.com/saleon/vehicles/cars/honda-civic_i28 ) I want to add '.htm' at the end of each url. So that my url would look something like this ( http://myhost.com/saleon/vehicles/cars/honda-civic_i28.htm ). Does anyone has a clue how to do that in htaccess. My .htaccess code is as follow:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /saleon/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /saleon/index.php [L]
</IfModule>
Thanks for the help.
There's no need to do that in the .htaccess. You can change that in the oc-admin: Settings > Permalinks and then click on Show rules.
For example, the default permalink for the listing looks like this: {ITEM_TITLE}-i{ITEM_ID} and it generates the url as you mentioned before. However, if you change that value for the following one you will obtain an url ending with .htm: {ITEM_TITLE}-i{ITEM_ID}.htm.
Related
i'm learning how to rewrite urls and im trying to do that in my ubuntu server. I managed myselft to activate the Allowoverride All and i have htacess working.
I want to change this url for example:
http://serverismai/myapi/public/rest/navigate.php
And i try to do it like this :
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^home(.*)$ myapi/public/rest/curso/navigate.php/$1 [L]
</IfModule>
I've tried various solutions but this was the closest i got. The url dosent change automatically but if i insert http://serverismai/myapi/public/rest/home i see a blank page with some of my website html written ( not even the html of the page i'm trying to rewite url).
I'm pretty new to this so i want to know if there is something wrong in the Rewrite Rule or if my error is somewhere else...
Thank you!
You can use this code in your /myapi/public/rest/.htaccess file:
RewriteEngine On
RewriteBase /myapi/public/rest/
RewriteRule ^home/?$ curso/navigate.php [L,NC]
I am working on a php redirect script which 302 redirects visitors to other sites when they access a redirect url..
The script gets a variable (id) from the url and then redirects the visitor to the specific page.
The url structure is : example.com/redirect/index.php?id=test
At the moment all redirects work if I use "ugly" urls, but I want to strip all unnessecary information out of the url with .htaccess rewrites for better usability.
Which .htaccess rewrite rules do I need to make the above shown urls look like : example.com/redirect/test
I am currently using the following .htaccess rules
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule (.*) ./index.php?id=$1 [L]
</IfModule>
but they only work for urls like example.com/redirect/index.php?id=test if I try example.com/redirect/test I get a 404 error page.
It might be good to know, that I have 2 .htaccess files, one in my root directory and one in the root/redirects/ directory.
Best regards !
Try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/([^/]+)?/?([^/]+)?/?([^/]+)?/? [NC]
My first question here! :) Hello!
I have some trouble with .htaccess.
http://www.domain.com/subdir/?parameter=example works.
http://www.domain.com/subdir/example doesn't work.
When i try this:
RewriteBase /subdir
RewriteRule ^index.php - [L]
RewriteRule ^([^/]+)/?$ index.php?i=$1 [R,L]
i get an 404.shtml error like http:// www.domain.com/subdir/index.php?i=404.shtml
Also the wp-admin(http:// www.domain.com/wp-admin/) redirects to the subdir with 404.shtml. How do i get the url like http:// www.domain.com/subdir/example/
Can anyone help me?? Thnx in advanced!
Assuming this is a WordPress installation (based on the mention of 'wp-admin'), you want the following
Just use the WordPress standard, put this .htaccess into the root folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdir/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdir/index.php [L]
</IfModule>
Go to Settings and change Site address (URL) under General Settings to http://www.domain.com/subdir/
Put the following index.php into the root folder
<?php
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require('./subdir/wp-blog-header.php');
?>
Go to Settings > Permalinks and change the permalink structure to whatever you need
p.s. to access wp-admin you need to navigate to http://www.domain.com/subdir/wp-admin/
more info here: http://codex.wordpress.org/Moving_WordPress#Giving_WordPress_its_Own_Directory_While_Leaving_the_WordPress_Index_File_in_the_Root_Directory
I have a list of URLs such as,
http://www.mywebsite.com/page.php?genus=A_GENUS&species=A_SPECIES&id=12345.
I would like to write a .htaccess which permanently redirects visits to this form of URL to the following URL,
http://www.mywebsite.com/species/A_GENUS/A_SPECIES.
Is it possible to do this without having to manually list each species in the database?
I've tried to look it up but my head is in WordPress-Custom-Post-Type land and as such my brain isn't functioning properly. Any help would be greatly appreciated.
EDIT: Clarification
Currently my .htaccess is completely empty. I am re-writing my website to use an entirely new CMS and this new URL format. The old URL format will cease to exist but all of the information will still be used.
We are quite highly ranked for a lot of species on Google and I would like visitors from there to be able to view the information they require despite the URL format changing.
These changes haven't occurred yet (still using a Sandbox environment for the new version of the site) and I'd like to make the URL changes just before I "go live" with the new version.
EDIT 2: New site .htaccess
The contents of the new site's .htaccess looks like this in its entirety:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sandboxfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sandboxfolder/index.php [L]
</IfModule>
# END WordPress
EDIT for Garmen's answer
RewriteEngine On
RewriteBase /sandboxfolder/
RewriteCond %{QUERY_STRING} genus=([a-zA-Z0-9-]+)&species=([a-zA-Z0-9-]+)
RewriteRule ^profile.php$ /species/%1/%2 [R=302]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sandboxfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sandboxfolder/index.php [L]
</IfModule>
# END WordPress
Not sure if I've used RewriteBase correctly there, but it doesn't appear to function with or without it.
Regards,
RewriteEngine On
RewriteCond %{QUERY_STRING} genus=([a-zA-Z0-9-]+)&species=([a-zA-Z0-9-]+)
RewriteRule ^page.php$ /species/%1/%2? [L,R=302]
This one assumes a very specific order of query string parameters. So be warned. Also it assumes the names only contains plain letters, numbers, or dashes.
Change 302 to 301 when you are done testing. I used 302 because 301's are aggressively cached by browsers, making debugging very difficult.
EDIT: You should add this above the other rewrite rules you have, or it will not work.
EDIT 2: added a ? at the end to remove the querystring. And L flag to prevent further execution.
Some... fine person... has set up an incoming link to our site that looks like:
http://www.site.com/*our*-*services*/
I'd like to redirect it so it points it to:
http://www.site.com/our-services/
Ours is a Wordpress site so there's some rewrite stuff in our root htaccess file already. A rule that simply removes asterisks from the URL would do, but I can't figure out how to do that, so I tried the following - loosely based on copying the existing Wordpress rules - which isn't working:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} (/\*our\*-\*services\*/)
RewriteRule . /our-services/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
It looks like this rule is being ignored - the errant URL currently redirects you to our default Wordpress 404 page. Clearly, I am fail: what should I have put as the rewrite condition?
I'd remove your first RewriteCond and then just use this rule:
RewriteRule \*our\*-\*services\*\/ /our-services/ [L]
Well get them to change there incoming link.
Asterisks are reserved in urls, so in this case it shouldn't be used:
W3 Url Recommendation
Allowing asterisk in URL