.htaccess url aliasing for /r/var to #/r/var - .htaccess

I've tried going through the documentation for this but I'm definitely no sys admin. I'd like to create a ReWrite rule for my domain alienstream.com, so that alienstream.com/r/electronicmusic is aliased to alienstream.com/#r/electronicmusic
I know what the general form is going to follow
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/([a-zA-Z0-9]+)$ /#/?var=$1 [L]
</IfModule>
but I just don't understand the syntax for this

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
RewriteRule ^(r/.+?)/?$ /?sub=$1 [NC,L,R]

Related

.htaccess rewrite not working with my site

I have been trying to rewrite a url like this:
/gallery/test.php?id=1
to this:
/gallery/test/1
However it isn't working. I have url rewriting enabled and have used phpinfo() to check.
this is my code:
Options +FollowSymLinks -Multiviews
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine on
RewriteRule ^test/([0-9]+)/?$ test.php?id=$1 [NC,L]
</IfModule>
You probably need a rewrite base. Try adding the following on the line after the RewriteEngine on line.
RewriteBase /gallery/
this is a rewrite rule that should work
RewriteEngine On
RewriteRule ^gallery/test/([^/]*)$ /gallery/test.php?id=$1 [L]
Thanks

htaccess Sub Dir redirect

Is there anyway for me to redirect my subdomain index to my main domain?
From Subdomain.Domain.com/index or Domain.com/SubDomainFolder/index to just Domain.com
Tried several methods from StackOverflow, but yet nothing seems to take effect. Thank you
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 /
RewriteCond %{HTTP_HOST} ^(?:subdomain\.)?(domain\.com)$ [NC]
RewriteRule ^(?:SubDomainFolder/|)(index)/?$ http://%1/? [L,R,NC]

.htaccess remove pattern from url

is there any way to remove some pattern from url?
For exampple this is my pattern -=-something_dynamic-=-
and here is my url
_http://mysite.com/category/-=-something_dynamic-=-subcategory/
that I wish to become
_http://mysite.com/category/subcategory/
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 /
RewriteRule ^(category)/.*?(subcategory)/?$ /$1/$2/ [L,NC,NE,R=301]

url rewriting in php using .htaccess

I need to rewrite the url in my project.
I have a url like this
http://www.example.com/apps?platform=Android&category=Business&keyword=cows
and i need to rewrite this to http://www.example.com/apps/Android-Business-cows
How can i implement this url rewrite
I am cakephp framework in php.
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 /
RewriteRule ^(apps)/([^-]+)-([^-]+)-([^-]+)/?$ $1?platform=$2&category=$3&keyword=$4 [QSA,L,NC]
This will do (asuming you're using mod-rewrite on apache):
RewriteEngine ON
Options +FollowSymLinks -Multiviews
RewriteRule ^apps/([^-]+)-([^-]+)-([^-]+)$ apps?platform=$1&category=$2&keyword=$3

.htaccess rewrite url to arguments

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^products/([a-zA-Z]+)/([0-9]+)/$ index.php?product=$1&price=$2
This code makes
http://www.example.com/products/computer/1000
into
http://www.example.com/index.php?product=computer&price=1000.
Is it possible to make
http://www.example.com/scriptName/arg1/val1/arg2/val2/arg3/val3
into
http://www.example.com/scriptName.php?arg1=val1&arg2=val2&arg3=val3?
The user should be able to give an unlimited number of arguments. This way one can have /index.php?page=forum&subforum=subforum&quote1=postNo1&quote2=postNo43 and so on rewrite /index/page/forum/subforum/subforum/quote1/postNo1/quote2/postNo43
How would the .htaccess code look?
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 /
RewriteRule ^([^/]+)/([^/]+)/([^/]+)(.*?)/?$ $1/$4?$2=$3 [L,QSA]
RewriteRule ^([^/]+)/$ $1.php [L]
This will forward a URI of /scriptName/arg1/val1/arg2/val2/arg3/val3 to /scriptName.php?arg3=val3&arg2=val2&arg1=val1

Resources