How would be the .htaccess lines to make a Virtual Directory from a single php File?
www.domain.de/file.php should go to www.domain.de/file/
Not all php files, only a single predefined in this Case the file.php
Thanks!
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^file.php$ file/ [L]
</IfModule>
This is how I solved it:
DirectoryIndex index.php
RewriteEngine on
RewriteRule ^file/ file.php [L]
Options -Indexes
Related
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.
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]
I'm having some problems in my .htaccess file.
I would like to display the content of this URL:
http://mywebsite.com/admin/payments/invoices/view/index.php?id=123456
When I access this one:
http://mywebsite.com/admin/payments/invoices/view/123456/
Here's my actual .htaccess
Options +FollowSymlinks
RewriteEngine On
RewriteBase /admin/payments/invoices/
RewriteRule ^/view/([0-9]+)/(index.php)?$ /view/index.php?id=$1 [L,QSA]
Do you have any idea?
Thanks!
If you do have the view directory, then the easiest thing is to put this .htaccess in that directory (i.e. {DOCUMENT_ROOT}/admin/payments/invoices/view/.htaccess):
Options +FollowSymlinks
RewriteEngine On
RewriteBase /admin/payments/invoices/view
RewriteRule ^(\d+)$ index.php?id=$1 [L,QSA]
The index.php in the left side hand of the RewriteRule is not required (actually, I expect it not to work: the DirectoryIndex should not yet have been injected in the URI at this stage - unless some other RewriteRule is in effect?), nor is the / at the end of the RewriteBase.
I tested the above on Apache/2.2.21, but the module rules are the same for later versions.
Try this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^.*admin/payments/invoices/view/index\.php\?id=([0-9]+) admin/payments/invoices/view/$1/index.php [L]
</IfModule>
Try putting this in the htaccess file in your document root:
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)id=([0-9]+)
RewriteRule ^admin/payments/invoices/view/index\.php$ /admin/payments/invoices/view/%1/index.php [L]
So when you enter http://mywebsite.com/admin/payments/invoices/view/index.php?id=123456 in your browser's URL address bar, you will get served the content at /admin/payments/invoices/view/123456/index.php. Since it's completely unclear what you actually want, in case you wanted it the other way around:
RewriteEngine On
RewriteRule ^admin/payments/invoices/view/([0-9]+)/(index.php)?$ /admin/payments/invoices/view/index.php?id=$1 [L,QSA]
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"e1=postNo1"e2=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
Basically all I want to do is this:
I have a URL to a PDF files on the server in this location:
http://chudz.co.uk/philaletheians.co.uk/Study%20notes/Atlantean%20Realities/Atlantis'%20study%20-%20Appendices%20and%20Notes.pdf
Now I want to remove this section of the URL:
/Study%20notes/Atlantean%20Realities/
This is what I have done in my htaccess file and it does not work:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^/ /Study%20notes/Atlantean%20Realities/
I am new to this! as you can probably see above :) I have to keep the directory layout on the server as it is so my only option is to use mod_rewrite maybe?
Try adding the following to your .htaccess file in the root folder of your domain
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
#if request does not already start with /Study notes/Atlantean Realities/
RewriteCond %{REQUEST_URI} !^/Study\ notes/Atlantean\ Realities/ [NC]
#rewrite it to the /Study%20notes/Atlantean%20Realities/ directory
RewriteRule (.*) /Study\ notes/Atlantean\ Realities/$1 [L]