Forum Moderators: phranque

Message Too Old, No Replies

Just a basic .htaccess question

i guess it's very easy to do but i couldn't...

         

karma_75

5:42 pm on Aug 26, 2004 (gmt 0)

10+ Year Member



Hi there,

Really great forum; thanx a lot.

I have a problem with one of my sites which is constructed on a CMS system.

Problem = I don't want to show full path of module files of that CMS system. It simply shows paths like this:

"http://www.mysite.com/index.php?file=MyMessages" (or)
"http://www.mysite.com/index.php?file=MemberCorner"

But paths to files are actually like this:

"/site_root/modules/MyMessages/index.php" (or)
"/site_root/modules/MemberCorner/index.php"

...

As you see paths are already directed by CMS's creators ("http://..com/index?file=MyMessages" calls "/modules/MyMessages/index.php" file..). But I want to avoid this and make

"http://www.mysite.com/index.php?file=MyMessages"

address look like

"http://www.mysite.com/?MyMessages"

and/or

"http://www.mysite.com/AnyWord/AnyNumber/MyMessages"

I have nearly tried every rewrite rule that I can see on the manual and checked my regular expression syntax @ php.net, but it didn't worked.. Obviously there is something I can not see..

Just two of them are:

1 ========

RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]

2 ========

RewriteCond %{REQUEST_URI}!/$
RewriteCond %{QUERY_STRING} ^file=([^&]+)$
RewriteRule index.php$ esar/view/%1 [L]

I am sorry if those lines look rubbish to you; I'm a complete newbie (2-3 weeks) on Apache Server.

Can anyone suggest me something please?

Regards.

(PS: I know that rewrite engine is ON and working)

jdMorgan

10:39 pm on Aug 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



karma_75,

Welcome to WebmasterWorld!

In order to change the URLs you see in links on your pages, you will have to modify your script.

After you've done that, these links will be picked up by search engines and browsers, and will be used to access your site. Then you can use mod_rewrite to change those requested URLs back into the form that your script needs, if necessary.

Mod_rewrite works after a request is received by your server, but before any content is served and before any scripts are invoked. Because of this, mod_rewrite can change incoming URLs, but it cannot change URLs being "output" by your server as part of page content.

Jim

karma_75

9:23 pm on Aug 27, 2004 (gmt 0)

10+ Year Member



Thank you jdMorgan,

Is it the only way to activate the rewrite_mod?

Also my site is already in Google and it finds my site when I search..

It is so strange that it works this way.

jdMorgan

9:38 pm on Aug 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Is it the only way to activate the rewrite_mod?

Yes, see "Internal Processing - API Phases" in the mod_rewrite documentation [httpd.apache.org].

Jim