0

I tried everything on this world to make it work properly but it simply won't. I'm done with auto rewrite. You can still answer if you think you know what could be causing this but I doubt it's possible.

Question: How would I go on manually mod_rewrite each page like so:

domain.com/showthread.php?id=00 to domain.com/showthread?id=00

  • It needs to work with different thread ids. It needs to work with other .php pages as well but I can manually add each to .htaccess
  • It needs to redirect /page to /page.php but display /page in the url bar

(I have asked before (Remove .php from URL) how to automatically rewrite this but I just cannot get it to work properly and I'm running out on time and energy. and coffee.)

Issue:

Even though

<?php phpinfo(); 

Lists mod_rewrite as enabled

<?php if(!function_exists('apache_get_modules') ){ phpinfo(); exit; } $res = 'Module Unavailable'; if(in_array('mod_rewrite',apache_get_modules())) $res = 'Module Available'; ?> <html> <head> <body> <p><?php echo apache_get_version(),"</p><p>mod_rewrite $res"; ?></p> </body> </html> 

Displays "Module Available"

..it still does not function.

  • /page and /page/ return 404 in all cases
  • /page.php works like normal without bar rewrite or does not function at all.

I tried the following a.o.:

(1) # Apache Rewrite Rules <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteBase / # Add trailing slash to url RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$ RewriteRule ^(.*)$ $1/ [R=301,L] # Remove .php-extension from url RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^([^\.]+)/$ $1.php # End of Apache Rewrite Rules </IfModule> (2) RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^([^\.]+)$ $1.php [NC,L] (3) RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)$ $1.php (4) RewriteRule ^page$ page.php [L] 

Notes:

  • sudo service apache2 restart does not change anything.

  • Server reboot changes nothing.

  • I tried clearing other code inside, did not make any change.

  • I cleared my browser cache 100 times

ATTENTION:

Please read the post before answering. I'm pretty sure this is not your average mod_rewrite issue.

1
  • Can confirm that this is not the case. deny from all also works Commented May 22, 2015 at 18:17

1 Answer 1

1

I suppose your htaccess isn't working at all. Check in apache conf file for following ... AllowOverride None ...

and change it to AllowOverride All

Sign up to request clarification or add additional context in comments.

1 Comment

Found that in /etc/apache2/apache2.conf It was set to AllowOverride None But it was also using the wrong directory /var/www/ without html/ which is the old apache dir. None of my listed solutions worked properly though. I did it with stackoverflow.com/a/15940822/4191580 Works properly now (My search function seems to not work, but I'm unsure if it's related)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.