Solved

mod_rewrite in .htaccess

Posted on 2003-11-20
21
1,107 Views
Last Modified: 2010-03-04
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
0
Comment
Question by:tilmes
  • 8
  • 6
  • 6
  • +1
21 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 9789045
> 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.
0
 

Author Comment

by:tilmes
ID: 9789333
.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.
0
 

Author Comment

by:tilmes
ID: 9789390
Do i need also configure httpd.conf file?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 9795669
> Do i need also configure httpd.conf file?
yes, you need at least:
  AllowOverride AuthConfig
in each <Directory ...> where you want .htaccess
0
 

Author Comment

by:tilmes
ID: 9795832
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
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9798008
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
0
 

Author Comment

by:tilmes
ID: 9798235
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/
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9798422
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 ?
0
 

Author Comment

by:tilmes
ID: 9798633

<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/
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9798728
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...
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:tilmes
ID: 9799330
can i make it wotj with httpd.conf?

Please look at under the address
http://www.widmen.de/jula/scripts/DT_php1
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 9799561
> I don't have access to httpd.conf in server
you're lost
the server admin must enable .htaccess for you
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9799687
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]
0
 

Author Comment

by:tilmes
ID: 9799937
i don't know why, it doesn't work either.
0
 
LVL 16

Accepted Solution

by:
_nn_ earned 50 total points
ID: 9800367
Well then, you need to contact your hosting company to see what's going wrong here.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 9802216
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.
0
 

Author Comment

by:tilmes
ID: 9802233
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>
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 9802294
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
;-)
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9802515
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)
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 9806804
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é :-))
0
 

Expert Comment

by:joesremack
ID: 25642983
I am unable to url rewritting using php smarty.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now