There are a few folders where I house my django site that I want to be rendered as it would on any other non-django site. Namely, forum (vbulletin) and cpanel. I currently run the site with fastcgi. My .htaccess looks like this:
AddHandler application/x-httpd-php5 .htm
AddHandler application/x-httpd-php5 .html
AddHandler fastcgi-script .fcgi
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
AddHandler application/x-httpd-php5 .htm
RewriteCond %{REQUEST_URI} !(mysite.fcgi)
RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]
What are lines I can add so www.mysite.com/forum can not be picked up by django url and be rendered as it would do normally. Thanks.
in your apache vhost conf :
Alias /forum /home/django/project/forum
But i think its better to put your php stuff not inside your django project
You can do
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(mysite.fcgi) [OR]
RewriteCond %{REQUEST_URI} ^forum
RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]
This will ensure that the mysite.fcgi rule is triggered only if the url doesn't begin with forum.
Related
Below is the content of my .htaccess file on my site server.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I would like to block access to file requests in the folder notforyou (example of a request below):
http://my-cool-site.com/wp-content/uploads/notforyou/path/to/file.pdf
What rewrite conditions and rules can I add so that any file request from the folder like this can be redirected to another web page?
I added something like this at the top of the .htaccess but the files in notforyou can still be accessed:
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^wp-content/uploads/notforyou/(.*)$ http://example.com/ [NC,R,L]
add below code into your .htaccess
RewriteEngine On RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|pdf|png)$ http://www.yoursite.com/hotlink.gif [R,L]
You’ll need to change you yoursite.com to your domain name, and change hotline.gif to an image file on your server that explains hotlinking is disabled on your site.
I've not used URL rewriting on .htaccess for a while, and now I think I've forgot some of the basis.
This is my server directory structure:
https://www.domain.com/dir/
In which I've put my website, with those files:
index.php
list.php
edit.php
home.php
What I wanted to achieve is this: User writes url like https://www.domain.com/list and .htaccess sends that request to index.php?section=list.
So, this is my current .htaccess:
RewriteEngine On
RewriteBase /dir
Redirect on HTTPS
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteRule /([a-zA-Z]+)/$ /index.php?section=$1 [NC,L]
Testing it on htaccess tester seems to work as expected, but not on my webserver.
I've got no more .htaccess files in the server root dir, and by viewing server logs I only get Redirect to non-URL errors.
I've also seen this answer but it didn't help me so far.
Have this .htaccess in /dir/ directory:
RewriteEngine On
RewriteBase /dir/
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ index.php?section=$1 [QSA,L]
This will support pretty URL as http://domain.com/dir/list
How can i mod-rewrite to obtaining a pretty url like below
example.com
contains a form to get a text value and pass it another file for processing that file is in directory as web but i need to change that as pretty urls
example.com/web/index.php?url=mydomain.com
to
example.com/web/mydomain.com
example.com/web/newdomain.com
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 %{THE_REQUEST} ^[A-Z]{3,}\s/+web/index\.php\?url=([^\s&]+) [NC]
RewriteRule ^ /web/%1? [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^web/(.+?)/?$ /web/index.php?url=$1 [L,QSA]
I have this URL:
http://www.example.com/subf/subf2/download.php?token=6309838552568
It is possible to rewrite this url into this url?
http://www.example.com/subf/subf2/download/6309838552568
Note: If someone types a URL like this:
http://www.example.com/subf/subf2/download/6309838552568/sbuf3/subf4
i want to show them an error page.
Answer below
Hint: Include files like JS and CSS need to be refer in absolute paths.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT/subf/subf2/ directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /subf/subf2/
RewriteRule ^(download)/(\w+)/?$ $1.php?token=$2 [L,QSA,NC]
# to take care of css, js, images
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} \.php$
RewriteRule ^download/(.+)$ /subf/subf2/$1 [L,R=301,NC]
The path to my django site is: staging.ninjawebsite.com/clients/project/.
I want that to be treated as the base url. The django project is in the public_html/clients/project subfolder. Everything seems to be working fine but all links to say /city/ should go to staging. ninjawebsite.com/clients/project/city/ but it goes to staging.ninjawebsite.com/city/.
Here is my .htaccess file:
AddHandler fcgid-script .fcgi
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(admin_media/.*)$ - [L]
RewriteCond %{REQUEST_URI}!(django.fcgi)
RewriteRule ^(.*)$ /clients/project/django.fcgi/$1 [QSA,L]
Somebody please help me! Thanks.