htaccess - webapp in a subfolder doesn't work - .htaccess

I have a custom webapp in a root folder like www.mypage.com in a hosting, now i need to move it in a subfolder like www.mypage.com/subfolder.
This is my .httaccess :
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z-_]*)/?([a-zA-Z-_]*)?/?([a-zA-Z0-9-_]*)?/?$ index.php?controller=$1&action=$2&id=$3 [QSA,NC,L]
</IfModule>
I understand that to make it works in a subfolder I need to modify the RewriteBase from / to /subfolder or /subfolder/ but I can't make it works.
What im doing wrong?

Related

Rewrite rules .htaccess file of Drupal

I have installed a Drupal site in www.example.com/beta
I am trying to do the following
Redirecting users to /beta when they hit www.example.com which I have achieved
RewriteBase /beta
Modify the URLs. For example www.example.com/beta/products should be modified to www.example.com/products. I just need to remove the /beta from the url.
You can do it by this code:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^beta/(.*)$ /$1 [L,NC,R]
Regards.

How to copy functionality of RewriteRule & RewriteBase

I have the following at the document root of my server i.e. www.doodle.com/.htaccess
Options +MultiViews
ErrorDocument 404 /x/404.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^view/([a-f0-9]{40})/$ ./view/index.php?profile_id=$1
</IfModule>
This produces the following:
www.doodle.com/view/32e3234eafsd/
Say I wanted to copy the exact functionality within a sub directroy i.e. www.doodle.com/x/
and produce the following:
www.doodle.com/x/view/3223433242/
Notice the /x/ subdirectory, Am I missing a simple trick here?
Can you help with a solution?
Thanks
Just add the /x/ subdirectory:
RewriteRule ^x/view/([a-f0-9]{40})/$ /x/view/index.php?profile_id=$1 [L]
If you wanted to copy the htaccess file into a directory named "x", then you need to modify your rewrite base:
Options +MultiViews
ErrorDocument 404 /x/404.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /x/
RewriteRule ^view/([a-f0-9]{40})/$ view/index.php?profile_id=$1 [L]
</IfModule>
and get rid of the ./ in front of the rule's target.

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

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]

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 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