.htaccess 2 Dyanamic Rewrite URL - .htaccess

I have a dynamic url at
http://www.technicae.net/cgi-bin/type/mt-search.cgi?IncludeBlogs=2&tag=2%|tag|&limit=20
where the '|tag|' and '20' part change depending on the tag. This is Movable Type blogging platform which is written in perl. The '|tag|' part is a place holder for the tag. For example, if the tag was 'there' the url would be
http://www.technicae.net/cgi-bin/type/mt-search.cgi?IncludeBlogs=2&tag=2%there&limit=20
and not
http://www.technicae.net/cgi-bin/type/mt-search.cgi?IncludeBlogs=2&tag=2%|tag|&limit=20
I was wondering how to rewrite that in htaccess because everything I try doesn't work. I want it to be
http://www.technicae.net/tag/|tag|
instead of
http://www.technicae.net/cgi-bin/type/mt-search.cgi?IncludeBlogs=2&tag=2%|tag|&limit=20
can you please help me?
note
The URLS are not functional.

This is what you're searching for :
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^tag/([^/]+)$ cgi-bin/type/mt-search.cgi?IncludeBlogs=2&tag=2%$1 [L]
RewriteRule ^tag/([^/]+)/limit/([^/]+)$ cgi-bin/type/mt-search.cgi?IncludeBlogs=2&tag=2%$1&limit=$2 [L]
This will allow thos kind of url :
www.domain.com/tag/<myTag>
www.domain.com/tag/<myTag>/limit/<myLimit>
But not :
www.domain.com/limit/<myLimit>

Assuming you are using Apache, make sure you have mod_rewrite enabled.
The .htaccess you should use (this may need tweaked) is:
RewriteEngine On
RewriteRule ^tag/([^\.]+)$ cgi-bin/type/mt-search.cgi?IncludeBlogs=2&tag=2%$1&limit=20 [NC,L]

Related

htaccess - the second url param is not visible

example.com/play/music to example.com/play.php?c=music
here is my code which works:
RewriteRule ^play\/music$ play.php?c=music [L]
now I have an extra url param (id as integer) added:
example.com/play/music/54
need to be - example.com/play.php?c=music&id=54
here is my beginning try:
RewriteRule ^play\/music/\d+/?$ play.php?c=music&id=$1 [L]
the page is there but problem is with id param - php doesn't see it
could someone help and explain ?
also, maybe is possible to join both rules (with and without id) in one ?
With your shown samples, please try following .htaccess rules file. Make sure to clear your browser cache before testing your URLs and make sure your .php files(eg: play.php etc) are residing along with .htaccess rules file.
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ $1.php?c=$2&id=$3 [QSA,L]

Htaccess for redirecting a directory to a file with the same name

After doing a quick lookup on how to manage sites with multiple language support, I find site.com/language/page/ the neatest url layout. (as I don't have the funds for site.language)
I have used htaccess to redirect the base site from site.com to site.com/language/
by using: RedirectMatch ^/$ /language/ where 'language' is language.html
But since I have a directory called /language/ so that all other pages in the given language can be put inside it, the site just shows up as the index of the directory.
How can I accomplish that kind of layout, if I want the main index page to show up in the url as site.com/language/ ?
Current htaccess that worked fine until I added the directory:
## Rewrite Defaults
RewriteEngine On
## Remove file extension + force trailing slash
RewriteCond %{REQUEST_URI} (.*)/$
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule (.*)/$ $1.html [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule .* %{REQUEST_FILENAME}/ [R=301,L]
## Redirect to /en-gb
RedirectMatch ^/$ /en-gb/
With the root folder looking like:
/language
stuff.html
morestuff.html
language.html
...
I would really appreciate help as this is currently a nightmare situation. When I try compiling the htaccess with answers to similar questions, everyone has just parts of what I am looking to achieve and thus I break the layout with every modification...
Is it possible to change the back-end filenames and accomplish this layout using only htaccess for front-end url rewriting since the url bar is the only thing that matters?
If I understand correctly, you should be able to solve this by removing the line:
RewriteCond %{REQUEST_FILENAME} !-d
Let me know if that works.

SEO Friendly URLs & .htaccess

I'm trying to make my URLs SEO friendly but am having issues with my .htaccess
This is how my URL currently looks:
http://www.mysite.com/dns/?domain=stackoverflow.com&submit=Report
But I want it to show like this:
http://www.mysite.com/dns/stackoverflow.com
I've tried so many things I don't know if it's even possible to do so I just wanted to start over with guidance from you guys. The .htaccess I'm working with is in the /dns/ folder. Any help would be greatly appreciated.
Step 1: change all of your links and anchors in all of your pages to look like this: http://www.mysite.com/dns/stackoverflow.com, so when someone clicks a link on your site, they go to a link that looks like http://www.mysite.com/dns/stackoverflow.com instead of http://www.mysite.com/dns/?domain=stackoverflow.com&submit=Report
Step 2: In the htaccess file in your document root, add these rules (above any rules that you may already have):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?dns/(.+)$ /dns/?domain=$1&submit=Report [L,QSA]
Step 3: In the event that a GET method form submission is generating the link, you can add these rules too:
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /dns/\?domain=([^&\ ]+)(&submit=Report)?
RewriteRule ^/?dns/?$ /dns/%2? [L,R=301]
See post url rewritin using .HTACCESS
www.mysite.com/dns/?domain=stackoverflow.com&submit=Report
to
www.mysite.com/dns/stackoverflow.com/Report
Try this
Options +FollowSymLinks
RewriteEngine On
RewriteRule \.(js|css|jpe?g|png|gif)$ - [L]
RewriteRule "^dns/([ \w-]+)/([ \w-]+)/?$" dns/?domain=$1&submit=$2 [L,QSA]

Kohana URLs including index on redirects and pagination

I am having an issue with the KO3 core inserting index.php into my URL's when I use redirect
Request::instance()->redirect('something'); or $paginationStuffHere->render().
The result of either of these is http://www.something.com/index.php/something
This is not an issue when I use full URL's for the redirects instead of relatives such as Request::instance()->redirect('http://www.something.com/something'); but there is not really a way to do this with the pagination functions... that I have found, so I really need to find where it is adding this index.php
This does not occur when I use View::factory('something/something')->render(); which is the only thing I have been able to find people having similar problems with
The base URL is set to '/' in bootstrap.php
My .htaccess looks like this
RewriteEngine On
RewriteBase /
RewriteRule ^(application|modules|system) -[F,L]
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule .* index.php/$0 [PT,L]
Thanks in advance for any suggestions.
Find Kohana::init() in your bootstrap.php and set index_file to FALSE in that array

SEO friendly URL's with .htaccess

Can anybody please help me with some URL rewriting?
I have (for example) these pages:
www.mydomain.com/test/gallery.asp?id=2
www.mydomain.com/test/gallery.asp?id=3
and want them to be requested as:
www.mydomain.com/photos/people
www.mydomain.com/photos/wildlife
I'm using IIS and at first my hosting provider was using ISAPI_Rewrite with a httpd.ini file, now they have switched to Helicon Ape with a .htaccess file.
See: http://www.isapirewrite.com/ and http://www.helicontech.com/ape/
I tried it the ISAPI_Rewrite way:
RewriteRule /photos/people /test/gallery.asp?id=2 [I,L]
RewriteRule /photos/wildlife /test/gallery.asp?id=3 [I,L]
But it doesn't work.
Suggestions?
try this
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^photos/(.*)$ test/gallery.asp?id=$1 [L,QSA]
first row is test if it isn't file
second row is test if it isn't directory
third will redirect photos/wildlife?a=true to test/gallery.asp?id=wildlife&a=true
if you don't want to redirect with a=true, just give out QSA ;)

Resources