Jump to content

can't the hang on mod_rewrite


Utherr12

Recommended Posts

I followed http://www.easymodrewrite.com/guide-syntax on how to make http rewrites but it doesn't work. I've enabled the mod and placed .htaccess in /game/changelogThe file contains:Options +FollowSymLinksOptions +IndexesRewriteEngine OnRewriteBase /RewriteRule ^changelog/([0-9]+)$ index.php?rev=$1i want to replace index.php?rev=X with changelog/X

Link to comment
Share on other sites

I followed http://www.easymodrewrite.com/guide-syntax on how to make http rewrites but it doesn't work. I've enabled the mod and placed .htaccess in /game/changelog
I could be wrong here, but it sounds like you might be confused about why people use rewrites. Usually one of the most frequent uses of a rewrite is to give the appearance of directories without having actual directories for something. Most people wouldn't create a "changelog" directory if they're just going to create a rewrite that creates the appearance of a "changelog" directory. If you could give me a better idea of your directory structure and what you're trying to do I can help. e.g. where is the index.php file that you're rewriting to?
Link to comment
Share on other sites

folder changelog contains:.htaccessaddrev.phpbgsound.mp3index.phprev_page.phpi dont want my url to look like ...game/changelog/index.php?rev=X i want it to look like ...game/changelog/X

Link to comment
Share on other sites

folder changelog contains:.htaccessaddrev.phpbgsound.mp3index.phprev_page.phpi dont want my url to look like ...game/changelog/index.php?rev=X i want it to look like ...game/changelog/X
Ok, well I don't have much experience with nesting .htaccesses in different directories, but this is what I would do:
Options +FollowSymLinks +Indexes -Multiviews # always good to turn Multiviews off, this can cause a lot of problems with rewritesRewriteEngine OnRewriteBase /game/changelog # this might always be relative to the current directory anyway, not sureRewriteRule ^(\d+)/?$ index.php?rev=$1

But, if I were doing this myself, I probably wouldn't even have a changelog directory. I would rather have one .htaccess file in the main directory which does all the work, or I would probably create a changelog.php file and place it in the "game" directory, and have the rewrite ensure that everything works accordingly.

RewriteRule ^game/changelog/([^/]+)/?$ /game/changelog.php?val=$1 [QSA,L]

and then in changelog.php:

if (isset($_GET['val']) {   if ($_GET['val'] == 'add') {	  //addrev.php code here   } elseif ($_GET['val'] == 'rev') {	  //rev_page.php code here   } else {	  //index.php?rev=$_GET['val'] code here   }} else {   echo('whatever here.');}

You could then visit "/game/changelog/add", "/game/changelog/rev", or "/game/changelog/[number here]".

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...