Ok I'm new to ht access and i have been scouring the web for an answer on this. I currently am using the Interspire shopping cart and the add certain paths in the urls, for example: categories, products, pages and brands before the real SEO part of the url begins. It sucks. I'm looking for a way to get rid of this in for of a mod_rewite in htaccess. Here are some more visual examples:
Current: cases.com/categories/Amazon-Kindle-Cases/
Want it to be this: cases.com/Amazon-Kindle-Cases/
Current: cases.com/products/Piel-Frama-559-iMagnum-Black-Leather-Case-for-Amazon-Kindle-Fire.html
Want it to be this: cases.com/Piel-Frama-559-iMagnum-Black-Leather-Case-for-Amazon-Kindle-Fire.html
Current: cases.com/brands/PDair.html
Want it to be: cases.com/PDair.html
Current: cases.com/pages/News.html
Want it to be: cases.com/News.html
Do I need a rewrite for each one or can this be done in one. Thanks
RewriteCond $1 ^(products|brands|pages|categories)
RewriteRule ^(products|brands|pages)(.*)$ $2 [L]
Is that working?
more specifically:
RewriteEngine on
RewriteCond $1 ^(products|brands|pages|categories)
RewriteRule ^(products|brands|pages)(.*)$ http://cases.com$2 [L]
Related
I converted a website I'm building into a web view app in iOs.
I would like to track visitors that use the app instead of the website by adding a directory to my URL.
For instance, the "about" page URL would go from "https://example.com/about/" to "https://example.com/app-ios/about/"
My question is how to write an htaccess rule that tells my server to go to the path "/about/" and skip the "/app-ios/" directory?
Also, I'd like to add ?app=app-ios in my query parameters.
The most promising thing I found was this :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^search/node/(.+)$ /search/node/?app=$1 [QSA,NC,L]
But I'd need to specify what comes before "foo".. In my case, "app-ios" is at the beginning of the request uri, always.
Plus I don't want a redirection. I just want my server to read /app-ios/something/other-thing/ as /something/other-thing/?app=ios.
First one question for tracking I would recommend to make this over a Query Parameter (as you wrote) like ?client=ios, but this might be an own opinion.
For rewriting the URL you could do the following:
to remove from the IOS from the URL (not tested):
RewriteEngine On
RewriteRule (.*)ios/(.*) $1/$2?client_id=ios&%{QUERY_STRING} [L]
I've tried for ages to fix this problem that I have.
On my website I have rewriten some links with the htaccess file. The htaccess file currently looks like this:
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?sideID=$1
RewriteRule ^([a-zA-Z0-9_!-]+)/([a-zA-Z0-9_!-]+)/([a-zA-Z0-9_!-]+)$ index.php?sideID=$1&id=$2&title=$3
RewriteCond %{HTTP_HOST} ^www\.mypage\.no$
RewriteRule ^/?$ "http\:\/\/mypage\.no\/" [R=301,L]
The first rule rewrites from:
http://mypage.com/index.php?sideID=home
To this:
http://mypage.com/home
The first rule rewrites from:
http://mypage.com/index.php?sideID=b&id=12&title=a-great-blog-post
To this:
http://mypage.com/b/12/a-great-blog-post
Soo they do what I want too when it comes to rewriting I guess. BUT, the problem is that if im now navigated to any blog post on the site and then tryies to navigate back to whatever other link lets say http://mypage.com/home it will add http://mypage.com/b/12/home instead. That can of course be fixed easily by just using absolute URL's in the navigation. But when I try to make a XML Sitemap, the bot will index every page for each blog ID like so: http://mypage.com/b/12/home, http://mypage.com/b/13/home, http://mypage.com/b/14/home and so on for each blog ID and pagename.
Is there a way to make sure the RewriteRule's apply seperatly or set a condition for them or something like that?? I am a bit noob in this area.
I beg you, please help me! :)
I have a custom php script, each having a page for page.php?id=[number] and page.php. I've read a few .htaccess tutorials but I don't know which one is the most appropriate way of doing it:
Example,
page.php?id=12 to page/id-12/and
page.php to page/ AND page
Here's what I currently have:
RewriteEngine On
RewriteRule ^category/([0-9])$ /category.php?id=$1
RewriteRule ^category/$ /category.php
Code above returns 404 not found if i access category but appears okay if i access category/ (with a slash)
All your rules include the slash / at the end of category, thus of course category cannot match it.
RewriteRule ^category/?$ /category.php
The ? after / makes it optional
I'm working on a Business Directory Website. What I'd like to do is transform the URL String of :
http://www.website.co.uk/business/results.php?category_id=11
To http://www.website.co.uk/business/Financial & Legal
How do I achieve this? Not too sure on the Rewrite Rules etc I am to use.
Thanks for any help, in advance.
I am now trying jut a test on a local host.
The HTML Code is as follows :
<h1>This is the PHP file.</h1>
Link Here
So all I want is the URL to be http://localhost/mod_rewrite/index.php/category
rather than : http://localhost/mod_rewrite/index.php?url=category
The .htaccess file is as follows (But doesnt appear to work)??
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ /index.php?url=$1 [L]
Well,
in general you don't use ampersands in URLs.
They will be replaced by "%26" when you try to call them as a link.
But a general approach towards your question could look like that:
RewriteEngine on
RewriteRule ^business/Financial.*?Legal$ results.php?category_id=11 [L]
I have an existing page of /programs/kids.php that I want to load a category page from WP. I want the .htaccess file in /programs to handle this rewriting for me.
Something along the lines of:
RewriteEngine on
ReWrite kids2.php http://www.mysite.com/blog/cat/kids/
Any help would be awesome.
If your sure mod_rewrite is enabled by apache, the it is simple as
RewriteEngine on
RewriteRule kids.php http://www.mysite.com/blog/cat/kids/
or
RewriteEngine on
RewriteRule ^programs/kids.php$ http://www.mysite.com/blog/cat/kids/
depending on location and strictness (^hhh$ matches the whole string)
The directive is named RewriteRule and not just Rewrite. So try this:
RewriteRule ^programs/kids2\.php$ /blog/cat/kids/
But if you want have requests to /blog/cat/kids/ rewritten internally to /programs/kids2.php (the exact opposite of what you’ve mentioned), try this rule:
RewriteRule ^blog/cat/kids/$ programs/kids.php [L]
You could also do an include for that kids.php in the content of an existing WP page, but you'd need the ExecPHP plugin installed.
Then kids.php would display as styled content inside a WordPress page. Which is sometimes desirable, from a site cohesiveness standpoint.
Something like this:
<?php require_once(ABSPATH. '/programs/kids.php');?>
Not exactly what you asked for, but maybe an alternative approach.