.htaccess correct format for RewriteRule - .htaccess

I have a "JQueried" page using tabs - Tab A, Tab B etc the tabs hide/show content based on a link like this: Tab 1 I am using jQuery Address Plugin v1.4
http://www.asual.com/jquery/address/ to create new page titles and a new URL for each tab. If you do not know the Address Plugin recreates the URL so the link #tab1 creates the URL page.html#tab1 but without a page refresh. It also changes the page title but is there any way to create an RewriteRule so that http://domain/page.html#tab1 can be called by say http://domain/tab1.html (where tab1,tab2 etc. have proper names not tab!)
Have tried but don't seem to get it to work. e.g.
Options +FollowSymlinks
RewriteEngine on
RewriteRule about.html /test.php#tab1 [NC]
suggestions please. Thanks in advance - oh the htaccess will go in the actual root folder

Sorry, I checked \#, it didn't work for me either.
How about redirecting to test.php?hash=tab1, and then:
if (isset($_GET["hash"]))
header ( "Location: test.php#".$_GET["hash"] );

Based on my comment above - I have just found this stackoverflow.com/questions/8606127/mod-rewrite-hash-tags so I guess can't be done –

Related

htaccess not working properly for sub url having more slashes

I am having 2 websites. Call it 5p_front (http://localhost/5p_front/) (Developed in OctoberCMS) and 5p_group (http://localhost/5p_group/) (Developed in CakePHP)
In 5p_front i have an .htaccess file and in which i put a condition which will redirect to 5p_group website as soon as it finds a word having 5p_group_login in url. Here is code below
.htaccess
RewriteRule ^5p_group_login.*$ http://localhost/5p_group [L,R=301]
So if someone tries to go here for example http://localhost/5p_front/5p_group_login , they will simply be redirected to here http://localhost/5p_group/ .
This works fine from home page and other subpages like about page for example http://localhost/5p_front/we-are-5p-group .
However i have one product inner page http://localhost/5p_front/product/10 and if i hover the menu item which allows me to redirect to login page, it is showing this url http://localhost/5p_front/product/5p_group_login and hence when i click on it, i am unable to redirect at http://localhost/5p_group/ as it is only recirecting to this current url only http://localhost/5p_front/product/5p_group_login which should not be the case.
Additionally, My Menu is coming dynamically and i have used Static Pages plugin to create menus which OctoberCMS provides and i have created "Login" menu link like below.
How can i redirect the url at http://localhost/5p_group/ even if the user is at http://localhost/5p_front/product/10 and clicks on "Login" link which is showing http://localhost/5p_front/product/5p_group_login if i mouse hover on it.
Can someone guide me here what should i do in this scenario.
Thanks
Your rule
RewriteRule ^5p_group_login.*$ http://localhost/5p_group [L,R=301]
when placed in 5p_front/.htaccess will affect only URIs that begin with /5p_front/5p_group_login (because of the leading ^ in your pattern) so /5p_front/product/5p_group_login will not match.
If you want to rewrite URLs that have 5p_group_login anyhwere, just use:
RewriteRule 5p_group_login http://localhost/5p_group [L,R=301]

Need to Redirect Category Page On Home Page of Lightspeed Based Webstore

I have some trouble with redirection of my category page to Home page.
Have category page www.example.com/sale-baby that want to redirect on home www.example.com from .Htacess.
Using Lightspeed Webstore for the website.
I try to use simple rule but its not working.
If possible can give right suggestion for that.
Thanks
Adam
RewriteEngine On
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
“L” indicates that it’s the last instruction and “R” means redirect, and “301” means a permanent redirect.
other way:
Position the cursor after the HEAD tag in the code.
http://www.newsite.com/newurl.html">
Hope it Help You..

How to remove bits from the url using the htaccess file?

Hi I am using joomla for my website and I would like to remove the bits in between my url.
The original URL:
"/calums/index.php/component/jsjobs/jsjobs/employer/"
The way I want it to be:
"/calums/employer/"
It would be great if some one can help me work out how to do it using the htaccess file.
Thanks.
first of all you need to enable SEF in Joomla to get rid of the /index.php/ part:
enable sef in global configuration (the first two checkboxes)
copy your htaccess.txt to .htaccess
This is transparent and should make your URL look like this:
/calums/component/jsjobs/jsjobs/employer/
Then, by looking at your URL, it appears the component jsjobs doesn't have a menu item associated. Menu items are associated with views, so you should go into menu manager and add a new menu item and try to setup menu items for jsjobs. You might not find one that matches exactly but you should be partway there.
Once a menu item is setup (and the cache is cleared) you should begin to see
/component/jsjobs replaced at a minimum. If there is no menu item that produces the right url, then you might have to create an .xml file in the component/view folder you desire. More details in this answer: Joomla Developement :: Probleme with URL Rewriting
my first answer on stackoverflow. try this:
RewriteEngine on
RewriteRule ^(\w)/(\w)/(.*) $1/index.php/component/jsjobs/jsjobs/$2/$3

Multiple subdirectory error with mod_rewrite

I am trying to use mod_rewrite manually in joomla, and I have the following Rule:
RewriteRule ^test/(t1|t2|t3)-(.*).html$ /index.php?option=com_jumi&fileid=39&$1=$2 [L,NC]
So that I want the url
http://www.mysite.com/index.php?option=com_jumi&fileid=39&t1=foo
be displayed like
http://www.mysite.com/test/t1-foo.html
The rule works correctly, but when I am in the rewritten page the links like
http://www.mysite.com/link.html
or
http://www.mysite.com/xxx/link.html
become
http://www.mysite.com/test/link.html
or
http://www.mysite.com/xxx/test/link.html
respectively.
any suggestions?
thank you
You are using relative urls in your page. Your page contains a link like <a href="link.html">... and the browser makes the links relative to the current 'folder', namely "test", so when clicked the browser loads /test/link.html.
You should just use root-relative urls. So the link should become more like <a href="/link.html">.... The leading '/' makes the browser load the page relative to the root ("/"), not relative to "/test/".

url rewrite rule

so my first page is index, then from index i call a page called vetements where i include a get variable called cat wich is the category of wear, then when im on vetements page i call a sub category(here i stay on vetements page(the page redraws itsel with php) the problem is im unable to combine this 2 rules in htaccess
my links should look like:
vetements-Robes-Robes-courte
vetements is the name of the page itself
Robes is category
Robes-courte is sub category
right now this rule works when im on page vetements:
RewriteRule ^vetements-(.*)-(.*-.*) /vetements.php?cat=$1&sous_cat=$2 [L]
but it wont work when i go from index to vetements, to make it work from index to vetements i have to do the following:
RewriteRule ^vetements-(.*)-?(.*-.*)?
but then it wont work in vetements(when i redraw the page to call the sub category)
thanks for your help
maybe try a rewerite like this:
RewriteRule vetements-cat-(.*)-sous_cat-(.*)\.htm$ vetements.php?cat=$1&sous_cat=$
this is what was suggested by http://www.webconfs.com/url-rewrite-tool.php
You might also want to look at other tutorials and examples on creating so-called "search-friendly URLs" since that's essentially what you're trying to accomplish.
Does your index page have vetements-Robes-Robes-courte in the link to vetements page?

Resources