Jump to content

Mod_rewrite And Frontpage


vimalus

Recommended Posts

Hey guys,

 

I tried to modify .htaccess through file manager in cpanel. But once I modified.htaccess file, frontpage doesn't allow me to open my website and modify it. Anyone has this problem ?

 

I talked with tech support and they said I have to put .htaccess file in its original version in order to open website in frontpage !!! Then how do I use mod_rewrite ??

 

Moreover once I modify .htaccess file, it seems working, but I am still having problem with my scripts. Everything else works, but my script don't work. Any solution for that ??

 

Thanks for help guys,

 

Vimal

Link to comment
Share on other sites

Welcome to the forums, Vimal  :)

 

FrontPage makes it's own changes to the .htaccess files.  I don't use FP so I don't have an answer.  Maybe someone using FP will be able to help.

 

Moreover I didn't modify .htaccess file in FP. I modified it in file manager/edit file. But still after modifying .htaccess file, FP doesn't allow me to open website giving me FP Extension error. Well I submitted ticket and now its to 2nd level admin. So will see what happens.

 

Moreover as I said earlier, after inserting code for mod_rewrite, link works just fine but top navigation bar script disappears. Here is the code for .htaccess

 

RewriteEngine On

RewriteRule /agora.cgi/([0-9a-zA-Z]+) /store/agora.cgi?p_id=$1

 

So it should replace this link http://www.thecheapgifts.com/store/agora.cgi?p_id=00036

 

to

http://www.thecheapgifts.com/store/agora.cgi/00036

and it does. But script for top navigation bar disappears.

 

Thanks for help,

 

Vimal

Link to comment
Share on other sites

I know that you used cpanel to modify the .htaccess file but FP modifies it behind the scenes. I believe if you uninstall the extensions and reinstall them it will recreate the .htaccess file that FP requires.

 

As for what to use to do a site. I do mine by hand with a text editor. Don't use any fancy web site building programs.

Link to comment
Share on other sites

Welcome to the forums, Vimal! :)

 

Your navigation menu, as well as all of your other javascripts, do not work when you rewrite the URL in this form:

>http://www.thecheapgifts.com/store/agora.cgi/00036

...because of the way you link to them in your HTML code, and what both the browser and server do with those links.

 

Your navigation menu javascript is linked using the following code:

><script type="text/javascript" language="javascript1.2" src="menu.js"></script>

The "menu.js" is a relative link - in this case, relative to the URL of the page being displayed. With the above script appearing on a page at the above URL, the browser tries to fetch the script from this location:

>http://www.thecheapgifts.com/store/agora.cgi/menu.js

The "agora.cgi" part of the above URL is not a directory - it's your store CGI script. The server interprets the page request as a request for store/agora.cgi, thinking that "menu.js" is a parameter to the script instead of a file name. The server returns another copy of store/agora.cgi, and the browser tries to run the HTML code of your web page as a javascript (and fails). It is doing this for all 4 javascripts you are loading on the page.

 

When the URL to your web site is not run through mod_rewrite, the javascripts work because with a page URL like this:

>http://www.thecheapgifts.com/store/agora.cgi?p_id=00036

...a script tag linking to "menu.js" will try to retrieve the following file:

>http://www.thecheapgifts.com/store/menu.js

This file exists, so the server retrieves it, and the browser runs the javascript without any problems.

 

To fix this problem, you need to code the links to your javascripts so the server looks for them specifically in the /store directory, instead of in the directory the browser thinks the currently displayed page is in.

 

You'd need to change the code for your navigation menu from this:

><script type="text/javascript" language="javascript1.2" src="menu.js"></script>

...to this:

><script type="text/javascript" language="javascript1.2" src="/store/menu.js"></script>

This change will force the browser to get your javascript from the /store directory on the server, where it actually is. You need to make this same change to the other 3 script tags in your page.

 

I suspect a similar issue may be preventing you from editing your web site in FrontPage - that there's a relative URL or file/directory name in FrontPage's configuration somewhere that getting tripped up in the same way as your javascripts are.

 

Side note: Your web site has some serious structural problems - multiple <html>, <head>, and <body> tags and there should be only one set of each.

 

Hope this helps...

Link to comment
Share on other sites

Welcome to the forums, Vimal!  :)

 

Your navigation menu, as well as all of your other javascripts, do not work when you rewrite the URL in this form:

>http://www.thecheapgifts.com/store/agora.cgi/00036

...because of the way you link to them in your HTML code, and what both the browser and server do with those links.

 

Your navigation menu javascript is linked using the following code:

><script type="text/javascript" language="javascript1.2" src="menu.js"></script>

The "menu.js" is a relative link - in this case, relative to the URL of the page being displayed.  With the above script appearing on a page at the above URL, the browser tries to fetch the script from this location:

>http://www.thecheapgifts.com/store/agora.cgi/menu.js

The "agora.cgi" part of the above URL is not a directory - it's your store CGI script.  The server interprets the page request as a request for store/agora.cgi, thinking that "menu.js" is a parameter to the script instead of a file name.  The server returns another copy of store/agora.cgi, and the browser tries to run the HTML code of your web page as a javascript (and fails).  It is doing this for all 4 javascripts you are loading on the page.

 

When the URL to your web site is not run through mod_rewrite, the javascripts work because with a page URL like this:

>http://www.thecheapgifts.com/store/agora.cgi?p_id=00036

...a script tag linking to "menu.js" will try to retrieve the following file:

>http://www.thecheapgifts.com/store/menu.js

This file exists, so the server retrieves it, and the browser runs the javascript without any problems.

 

To fix this problem, you need to code the links to your javascripts so the server looks for them specifically in the /store directory, instead of in the directory the browser thinks the currently displayed page is in.

 

You'd need to change the code for your navigation menu from this:

><script type="text/javascript" language="javascript1.2" src="menu.js"></script>

...to this:

><script type="text/javascript" language="javascript1.2" src="/store/menu.js"></script>

This change will force the browser to get your javascript from the /store directory on the server, where it actually is.  You need to make this same change to the other 3 script tags in your page.

 

I suspect a similar issue may be preventing you from editing your web site in FrontPage - that there's a relative URL or file/directory name in FrontPage's configuration somewhere that getting tripped up in the same way as your javascripts are.

 

Side note: Your web site has some serious structural problems - multiple <html>, <head>, and <body> tags and there should be only one set of each.

 

Hope this helps...

 

Thank you very much for replying with such great explanation. But actually I tried all possible things that I could do. I tried with /store/; /store/html/ etc. I also tried to put those script files to different folders but nothing works. Just don't understand what's going on with this script. Well I will try to remove those extra tags and see if helps.

 

Thanks again,

Vimal

Link to comment
Share on other sites

Welcome to the forums, Vimal! I see David has pointed you in the right direction. As a former Frontpage user, I'll add that Frontpage is a great way to get websites up and running quickly. But if you're curious about how things work (aren't we all?), you find that you'll be spending more and more time in the HTML tab. Then once you get a little more experience under your belt, you'll ditch Frontpage and use something that will write pure HTML code without all of Micro$ofts clutter. There are many good programs out there...it just depends on your mood and desire to learn. Or you can, like Bruce said, just use Notepad and not have to purchase a thing!

Link to comment
Share on other sites

Thank you very much for replying with such great explanation. But actually I tried all possible things that I could do. I tried with /store/; /store/html/ etc. I also tried to put those script files to different folders but nothing works. Just don't understand what's going on with this script. Well I will try to remove those extra tags and see if helps.

But did you try what I suggested, exactly as I wrote it? What happens if you make the change, and can we look at the page after you've made the change?

 

I took a closer look at the mod_rewrite rule you're trying to use:

Here is the code for .htaccess

>RewriteEngine On
RewriteRule /agora.cgi/([0-9a-zA-Z]+) /store/agora.cgi?p_id=$1

So it should replace this link:

>http://www.thecheapgifts.com/store/agora.cgi?p_id=00036

to

>http://www.thecheapgifts.com/store/agora.cgi/00036

and it does. But script for top navigation bar disappears.

The rule you have actually does the reverse of what you say it does - it will take a URL like this:

>http://www.thecheapgifts.com/store/agora.cgi/00036

...and rewrite it to this:

>http://www.thecheapgifts.com/store/agora.cgi?p_id=00036

I don't know which way you intend for URLs to be rewritten. :)

Link to comment
Share on other sites

Thank you very much guys for helping me here. Well I tried a lot and then finally got tired. So I got new scripts from dynamic drive and actually it works perfectly with the same code and files !!

 

I think there were some settings required in those files and I didn't know it. But now it works. Actually I am experimenting these things on my other site so I don't screw up main website. Here check it out

 

http://www.vimal.us/store/agora.cgi?p_id=00019

 

and

 

http://www.vimal.us/store/agora.cgi/00019

 

Thanks again,

 

Vimal

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...