0

I'm making a CMS and trying to convert post links to pretty ones like so:

Original Link:

http://localhost/index.php?id=13&category=Uncategorized&title=just-a-link

Converted Link:

http://localhost/13/Uncategorized/just-a-test

I'm using Apache2 on Linux Mint and my website is located in:

var/www/html

I loaded mod_rewrite using sudo a2enmod rewrite then restarted apache2.

my apache2 config file is /etc/apache2/apache2.conf inside it i have:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride All
    Require all granted
</Directory>

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

#<Directory /srv/>
#   Options Indexes FollowSymLinks
#   AllowOverride All
#   Require all granted
#</Directory>

and here is my .htaccess file located in var/www/html/.htaccess

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /single.php?id=$1&category=$2&title=$3 [L]

I have also restarted apache2 several times, but it just doesn't work.

Here is the loaded modules from phpinfo, (you can see that mod_rewrite is loaded) (pls see two images below to understand what problem i'm having)

core mod_so mod_watchdog http_core mod_log_config mod_logio mod_version mod_unixd mod_access_compat mod_alias mod_auth_basic mod_authn_core mod_authn_file mod_authz_core mod_authz_host mod_authz_user mod_autoindex mod_deflate mod_dir mod_env mod_filter mod_mime prefork mod_negotiation mod_php5 mod_rewrite mod_setenvif mod_status

If i directly take $_GET values from url without mod rewrite it works but with pretty urls I can't get $_GET values anymore.

not pretty: http://i.imgur.com/FUc3Tuc.png

pretty: http://i.imgur.com/GIzOPpK.png

2 Answers2

0

This is not Apache issue. You need to remove 'p' tags from query string.

strangeman
  • 433
  • 5
  • 19
0

Doesn't make sense to put the tags in the querystring, you should either get rid of them and put them in the template, or urlencode them when you create the url.

$returnValue = urlencode('<p>another test</p>');

This results in "%3Cp%3Eanother+test%3C%2Fp%3E", so you can try http://localhost/index.php?id=13&category=Uncategorized&title=%3Cp%3Eanother+test%3C%2Fp%3E