Link to home
Start Free TrialLog in
Avatar of tilmes
tilmesFlag for Germany

asked on

mod_rewrite in .htaccess

I wrote this below in .htaccess file under directory /cgi-bin/AD_cla
It doesn't work with mod_rewrite. Need to do more in server?
I don't have a access to change mode in this server. And Does file .htaccess  work in directory cgi_bin?

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule cla/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/$ /cgi-bin/AD_cla/cla\.cgi?$1=$2&$3=$4&$5=$6&$7=$8
Avatar of ahoffmann
ahoffmann
Flag of Germany image

> And Does file .htaccess  work in directory cgi_bin?
if it is configured to do so, yes.
If it is not configured, then you're losst, means you need to do authetification in your CGI itself.
Avatar of tilmes

ASKER

.htaccess  file dosn't work in either in directory cgi-bin and non cgi-bin directory.
What do this file ned to be done to work properly?
I want to use mod_rewrite URL to make dynamic site spider friendly.
Avatar of tilmes

ASKER

Do i need also configure httpd.conf file?
> Do i need also configure httpd.conf file?
yes, you need at least:
  AllowOverride AuthConfig
in each <Directory ...> where you want .htaccess
Avatar of tilmes

ASKER

Could you please check two file?
It doesn't work now with those two.

### In httpd.conf
AllowOverride AuthConfig
<Directory /homepages/22/d234234/htdocs/tell/scripts/DT_php>
Options ExecCGI FollowSymLinks Includes MultiViews
</Directory>

### In .htaccess
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule detail/(\.*)/(\.*)/$ /tell/scripts/DT_php/detail\.php?$1=$2
Avatar of _nn_
_nn_

ahoffman is 100% correct : "you need at least 'AllowOverride AuthConfig' *IN* each <Directory ...> (...)"
Moreover, you'll see at http://httpd.apache.org/docs-2.0/mod/core.html#allowoverride that this directive *cannot* be used anywhere else than within a <Directory ...> section.

So if you're going to use it, try like this :

### In httpd.conf
<Directory /homepages/22/d234234/htdocs/tell/scripts/DT_php>
Options ExecCGI FollowSymLinks Includes MultiViews
AllowOverride AuthConfig
</Directory>

Now, I see a couple other problems in your directives :

>> RewriteRule detail/(\.*)/(\.*)/$ /tell/scripts/DT_php/detail\.php?$1=$2

1. The 'left' expression : detail/(\.*)/(\.*)/$ is a regular expression.

\. => means "the dot character"
. => means "any character" (usually, but the end-of-line one)

So, your regexp will match /detail/.................../...../  (is this the URLs you want to use ?), but will fail to match anything else like /detail/xxx/yyy/ or /detail/blah/blurps/

2. The 'right' experssion is NOT a regular expression, so you don't need to 'escape' the dots.

In the end, it gives when corrected:

RewriteRule detail/(.*)/(.*)/$ /tell/scripts/DT_php/detail.php?$1=$2


Last problem is where you put the .htaccess file itself. For such a RewriteRule, it needs to be either in / or in /detail (not sure), but certainly not in the /tell/scripts/DT_php/ one.

HTH
Avatar of tilmes

ASKER

Thank you. I really tried a lot but it dosen't work.
The original URL is like
http://www.abcd.de/tell/scripts/DT_php/index.php?kid=12&catname=Medical+%26+Health
http://www.abcd.de/tell/scripts/DT_php/detail.php?siteid=1304

and in the .htaccess is;
Options +FollowSymLinks
RewriteEngine on

RewriteBase /
RewriteRule tell/(.*)/(.*)/$ /tell/scripts/DT_php/detail.php?$1=$2
RewriteRule tell/(.*)/(.*)/$ /tell/scripts/DT_php/index\.php?$1=$2&$3=$4

I put the httpd.conf in /
and .htaccess tried both in / and /tell/scripts/DT_php/
httpd.conf should not be copied in the DocumentRoot or in any subfolder.

In httpd.conf :

<Directory /homepages/22/d234234/htdocs/tell>
Options ExecCGI FollowSymLinks Includes MultiViews
AllowOverride All
</Directory>

In /homepages/22/d234234/htdocs/tell/.htaccess :

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/tell/(.*)/(.*)/$ /tell/scripts/DT_php/detail.php?$1=$2 [L]

Now, please try http://www.abcd.de/tell/siteid/1034/

Btw, are you sure mod_rewrite is loaded ?
Avatar of tilmes

ASKER


<httpd.conf should not be copied in the DocumentRoot or in any subfolder.>
Where can i put otherwise httpd.conf? I don't have access to httpd.conf in server
because i get hosting service. I am sure they suppot rewrite mode and below is fag. from the company.
http://faq.puretec.de/skripte/php/10.html

I followed exactly yours.
I got a error 404 in
http://www.abcd.de/tell/siteid/1034/
If it's a hosting service, then you most likely don't have access to the httpd.conf file and creating one will not help at all.

Is abcd.de your domain name ? Because http://www.abcd.de/ doesn't work either, I can't even connect to the httpd daemon...
Avatar of tilmes

ASKER

can i make it wotj with httpd.conf?

Please look at under the address
http://www.widmen.de/jula/scripts/DT_php1
> I don't have access to httpd.conf in server
you're lost
the server admin must enable .htaccess for you
Is this puretec.de your hosting company ? If yes, did you simply try to follow that faq ? Something like

- no httpd.conf
- in the .htaccess file in your DocumentRoot folder :

RewriteEngine on
RewriteCond %{REQUEST_URI} tell/(.*)/(.*)/$
RewriteRule tell/(.*)/(.*)/$ /tell/scripts/DT_php/detail.php?$1=$2 [L]
Avatar of tilmes

ASKER

i don't know why, it doesn't work either.
ASKER CERTIFIED SOLUTION
Avatar of _nn_
_nn_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hmm, isn't the graded answer not a copy of my last one?
To all your questions I suggested that you need to modify httpd.conf.

Please take care when grading.
Avatar of tilmes

ASKER

I am sorry if something went wrong hoffmann.
How can i modify httpd.conf.?
There are already in httpd.conf
<Directory /homepages/22/d234234/htdocs/tell>
Options ExecCGI FollowSymLinks Includes MultiViews
AllowOverride All
</Directory>
Please reread this thread!
You have to have admin privileges to modyfy httpd.conf (which is used by the server).
Or you need to ask the server admin (or whoever at the ISP) to do it.

Wer lesen kann, ist eindeutig im Vorteil
;-)
ahoffmann, sorry for the mess, I butted in because I noticed a couple other problems in the regexps, I of course wasn't trying to grab points.

tilmes, if contacting your hosting company helped you, then ahoffmann's comment should have been accepted as an answer, not mine. You can get a moderator to undo that acceptance, post a request in the Community Support area.

Last, I assume that this server has many websites, in which case you *CANNOT* modify the httpd.conf file yourself and creating one in your folders will *NOT* have any effect.

Das Sprichwort kannte ich nicht, ist das ein "Klassiker" (es klingt so) ? (bin selber Franzose, kann aber ein wenig deutsch)
I don't care about the points, just to clarify what was the most helpfull answer, at least for future readers.
(Non, ce ne pas un proverbe, est plus comme une phrase, parsque tout le mond savoir ecrivé :-))
I am unable to url rewritting using php smarty.