PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

how to setup pretty urls and mod rewrite rules on linux apache2 web server

Go down

how to setup pretty urls and mod rewrite rules on linux apache2 web server Empty how to setup pretty urls and mod rewrite rules on linux apache2 web server

Post by jamied_uk 17th July 2015, 16:24

First type this command
Code:
a2enmod rewrite


Now this command

Code:
sudo gedit /etc/apache2/apache2.conf

Now look for the folder of your www folder




Example below shows what it should be for this to work.
Code:

<Directory /var/www/html/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>


now restart your web server (example of how to alias this as its very comon to want or need to restart your apache server!

Code:
alias srest='sudo /etc/init.d/apache2 restart'


now type


Code:
srest



Type password when asked and vala!

This is an example of your .htaccess file to enable a custom pretty url!

Navigate to your www folder and right click, select terminal and type the following command

Code:
sudo gedit .htaccess


 (# is a commented out line).

Code:

RewriteEngine on
# Redirect Rule
RewriteCond %{THE_REQUEST} \?u=([^&\ ]+)($|\ )
RewriteRule ^ /%1? [L,R=301]
# Redirect Writeback
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)$ /user.php?u=$1 [L]






For more information about alias and making it perminant alias search this forum for the word alias


Thanks For reading! Enjoy!
jamied_uk
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum